开发者

Design pattern for data entry forms with LINQ2SQL

I am about to start a new winforms data entry application, it already has the database designed which I am comfortable with.

I was going to use LINQ2SQL to access the ta开发者_如何学JAVAbles to keep things type safe but am now wondering about design patterns, something I am just getting into. Since LINQ is giving me objects to use should I still create classes in between to hold the validation code and helper methods or should these just go in with the UI?

It just seems I will end up with classes sat in between with little code which will cause the UI classes to have code just getting and setting values in the intermediate class and returning from validation to flag errors...

Any good reading on this? Should I consider the entity framework (or similar) instead?


The principle you are looking for is probably Separation of Concerns which you can leverage by using the Repository Pattern, a business logic layer (may incorporate several patterns) and keeping the UI doing nothing but presenting information (i.e. no business logic there). The MVC, MVP, MVVM patterns would all be good starting points there.

Good reading? Any software design patterns book but there are the canonical two: the GoF Design Patterns: Elements of Reusable Object-Oriented Software and Martin Fowler's Patterns of Enterprise Application Architecture are a good start.


Put linq2sql to you data access layer, which contains all the business logic and is available to the layer above. The linq2sql is using the domain model objects (table objects), which are strong-typed and you just need to pass the data wrapped up in domain object to the above layer. And you can access all the field in the object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜