views:

152

answers:

2

Currently in the early stages of developing a very large project using ASP.Net MVC.

At present we are using the standard format (Ie Folders for each of the Models/Views/Controllers) Allready I am starting to see a large codebase that has the potential to multiply 100x over and for the sake of future maintainability i'm considering moving all the Models and Buisness logic into a seperate class library, leaving the controllers and Views in the MVC project.

Does anyone have any thoughts on this? Has anyone has a similar experience?

+3  A: 

You absolutely should move your models in business logic into a separate library or libraries. I do this even for very small sites. There is essentially no disadvantage, and it allows you to use your models and business logic in non-web applications.

To clarify, I keep view/presentation models in the web project, and entity/domain models in the separate, model library.

Craig Stuntz
As for your DAL I assume you put that into your Library?
Pino
Yes, that's right.
Craig Stuntz
Lets say we have a viewModel call UserProfile and this is populated from the User Object (Linq 2 SQL Database table) where would you have the code that turns the User Object to the UserProfile view model?
Pino
I generally project from entities to view models inside a controller action. It's a trivial LINQ query, generally. When the queries become non-trivial, it's a more complicated question.
Craig Stuntz
Anyone aware of any samples of this kind of architecture?
Pino
A: 

Take a look at S#arp architecture.

It separates the Model, the Controllers and the Service layer in separate dlls.

It has also the concept of areas (that was recently also introduced in MVC2)

It's one of the best examples you can find for an MVC architecture for large projects.

Ronnie