I am learning ASP.NET MVC and looking at the ASP.NET MVC sample application NerdDinner.
The folder "Models" contains a class called Dinner.cs
. This is the main Dinner entity.
Shouldn't this class be in an other location? For example "Domain" ? And instead should a viewmodel class be put in the Models folder that contains dinner information?
Why is the file "PaginatedList.cs" located in the folder called: "Helpers". Shouldn't this file be in the folder: "Models" since it is supplied to views?
Any clearification on this would realy be appreciated!
Sure, your thinking is right about this. NerdDinner is made just for concept-presentation purposes and doesn't really pretends to all the best practices. It becomes more and more obvious as your own project grows. You will have your domain entities/services/repositories in separate folder, then separate project, then possibly separate solution. You will find yourself renamed this folder to ViewModels
to make it more obvious for other people working on project.
PaginatedList can be a ViewModel and contain data related to pagination. Then it can be put to ViewModels
folder. But I believe what you have in NerdDinner - is just a simple View helper to generate pagination markup. Moreover, helpers could be not that strict "View" or "ViewModel" - they can contain simple logic, they're somewhat in the middle :) between View and ViewModel. Also note that PaginatedList is more of a "framework" concern than of a "particular solution". So you can't place it to "Views" or "Models" folder amongst project-specific things. So "Helpers" is good enough for NerdDinner. In a real solution you'd better make it common, include it into your "framework" that is on top of MVC.