1

How should I logically define an ASP.NET MVC solution? Into how many projects must I divide my solution? Is there a standard approach for this? Like for example, a model class library, an MVC web application (comprising controllers & views), a unit test project, a repository project etc... What are the different types of project one can come up with?

Ash Biz
  • 13
  • 2

2 Answers2

1

The answer is really depends. Depends of the scale of your project. You can have it all in one project (main MVC one) of you can split it further. The canonic form for this projects is something like that:

project.WEB
project.Common (here belongs common functionality between projects, so helpers, utilities, even some extension methods belong there)
project.Model (Data entities)
project.BL //(Business Logic)
project.DAL //(Data Access Layer or Persistence)
project.Tests

*note the "project" is your namespace root. How ho handle namespace naming you can check it there: namespace naming conventions

And the you can split it further and further. However I would suggest that you do not exaggerate with splitting it any further. When you will have to do it you will know (one project grow too much, there are logic separations ...). You try to follow the principle YAGNI.

And one more thing. If you want to be there "by the book" check it out DDD - Domain Driven Desing: http://msdn.microsoft.com/en-us/magazine/dd419654.aspx.

Community
  • 1
  • 1
Peter Stegnar
  • 12,615
  • 12
  • 62
  • 80
  • Thank you very much for suggesting the canonical form for projects. However, can please tell me a bit more about project.Common? What should go into that? – Ash Biz Mar 07 '13 at 09:51
  • @ Ash Biz: Sure I will explain the purpose of the common in the answer itself. I happy that it helps. Basically purpose of the common project is that it can be shared among all solution projects if needed. And so here belongs some helpers, utilities, basic functionality, ... And not only that the idea is also that common project can be reused on other projects, so things there should not be (too much) domain specific. – Peter Stegnar Mar 07 '13 at 13:36
0

This is a very broad question, but i will give you an example of what I did on my previous project. Firstly, it will depend on the complexities of the overall application, and the developers personal preference. A simple app could very well fit inside a single MVC 4 application.

Web Project - for the views using MVC4
Application - for business logic)
Data - for repositories and webservice methods)
Domain - for the objects used in the app
Utilities - for common functionality that needs to be used in more than one project

The example above fitted the project very nicely allowed me to separate all the concerns making it more maintainable.

gdp
  • 8,032
  • 10
  • 42
  • 63