开发者

ASP.NET MVC Application Design

开发者 https://www.devze.com 2023-02-11 03:31 出处:网络
Ok, So I have been taking in all sorts of gre开发者_如何学Pythonat information about MVC, EF4, Repository Pattern, UoW, Service Layers, etc and now I am going to attempt to put it all together.

Ok, So I have been taking in all sorts of gre开发者_如何学Pythonat information about MVC, EF4, Repository Pattern, UoW, Service Layers, etc and now I am going to attempt to put it all together.

My question is, How should these be separated?

I was thinking projects like this:

1) Application - MVC App

2) Repository Layer 3) Entities - EF4/Partial Entity Classes

Any suggestions would be great!!

Thanks, Sam


Here's one example of how you could structure your application:

  1. Domain Models (Primary POCO objects)
  2. Repositories (Implementation of some data access technology depending on the project requirements : EF, NHibernate, LINQ to XML, Remote web service calls, ...)
  3. Service (business operations aggregating multiple CRUD operations into a business operation that will be exposed with the domain objects)
  4. ASP.NET MVC application (Controllers, Views, View Models, Mappers between the Domain objects and the view models)

This layers could represent a physical separation (assemblies) or logical separation into the same assembly.


Don't separate code physically until you have a physical reason to do so such as deployment or code sharing reasons. Use folders and namespaces.


I've just been through this myself and by far the best approach i found is S#arp Architecture.

Excellent templates generate the project scaffolding for you and they have a good explanation why u really do want physical project separation. Good argument here. Theyre tutorial shows how TDD with this model is a breeze.

The beauty of this model is the separation of concerns it offers so if you did want to use EF, its a snip to swap out NHibernate.

0

精彩评论

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