I am trying to start a new project (asp.net MVC) and I would like to apply some DDD rules I’ve learned in these last few months.
I don’t know how to organize my solution though.
I would like to use Nhibernate but I don’t want to use Fluent Nhibernate cause it must be something like an experiment.
I’ve seen some examples where people keep everything in the same project.
Some others tend to create a different project for everything.
Do you think I should differentiate the model and the repository or put it in the same project?
If someone has some links to articles etc it would be appreciated.
thanks
Alberto
I personally think dividing each layer into a separate project is a better idea. There are certain things that you cannot achieve with having 1 big ASP.NET MVC project that includes all your layers.
For example, assume you have a Product and ProductFactory class. You would like to enforce the creation of a Product object to be done via ProductFactory. To achieve this, you can make the constructor of Product class internal. This way, ProductFactory class can instantiate a Product class because Product and ProductFactory are in the same assembly. However, if you try to instantiate a Product class from another project (i.e. your ASP.NET MVC project), you will receive a compile-time error. This way you can achieve a better encapsulation.
Note that if Product, ProductFactory and your Controller are in the same project, you can still see the Product‘s constructor in your Controller. So an amateur developer who does not understand the architectural decisions behind your design and can simply ignore the ProductFactory and create a Product object directly.
Plus, having a separate project for each layer makes your maintenance easier because you have to deal with smaller projects, as opposed to 1 big project.