Geeks With Blogs
Lee Brandt's Blog You're only as smart as your last line of code

As I am learning about TDD and MVC, one thing comes up. How should I arrange my models, views and controllers? Of course, I know I need to set up the models view and cotrnollers folders for ASP.NET MVC, but what view actions should go into a controller? An example may help illustrate my question:

In the default project template for an ASP.NET MVC app, you get a HomeController which has to actions in it: Index and About. Should the about really be an action on the home controller?

I guess my initial reaction is to say that all actions within a controller should be part of that silo. In other words, If I have a HomeController it should have actions that only call models and views for getting and displaying "Home" information. A better example is, if I am creating a blog project, then I might have a BlogController and maybe an ArticleController. The BlogController should only have actions in it that get data for and render views for Blog-specific content. The ArticleController should only contain actions that get data for, and display views for Article-specific information.

Now, I am not trying to second-guess the ASP.NET MVC team. I am sure they are MUCH more expreienced than I am, I am just trying to undertand how people are arranging their Ms, Vs and Cs.

I would also welcome suggestions on arrangement of tests. I tend to create a test class file for each model, each view and each controller. But I've been thinking, people might put all controller tests in one file, and all Model tests in another, etc.. Or maybe a combination of both?



Posted on Monday, April 14, 2008 2:57 AM MVC , Learning | Back to top

Comments on this post: How do YOU arrange your ASP.NET MVC app?

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Lee Brandt | Powered by: