After watching this video, I am wondering if I am using my controllers wrong. What exactly should a controller contain?
For my blog, I have a post controller which has methods:
create
show
list
loadPost
like
dislike
Whereas my post model only has a few access rules, validation rules and relation information. Are there any examples of a MVC app on the web?
I highly recommend reading
http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/04/24/how-we-do-mvc.aspx
Here’s my incomplete list of what controller shouldn’t do:
Should do:
Bad:
Good
And by the way, I rarely see good MVC examples, including the NerdDinner. They all deal with business logic inside actions, no view models, and so on. This is usually OK for what they are intendet for – MVC features demonstration – but it shouldn’t be taken as good design examples. A more-or-less good examples is CodeCampServer, along with accompanion book ASP.NET MVC In Action. But not without its drawbacks (anemic domain model, for example).
But if do not try to follow domain driven design, and instead have a simple data-driven requirements, things can be easier for you.