Hi folks,
Imagine we were doing this StackOverflow site in ASP.NET MVC (funny that, 'cause it is...). We have to develop the views:
- About this site
- Faq
- Privacy policy
- 404 page
- Error page
- etc...
Now, because we want to keep this RESTful because we're trying to grow our RESTafarian Geek-fro's, do we throw them into one controller .. called .. (eeks... er..) MiscellaneousController or FrameworkController or Controller .. each one with their own action methods ...
or
Do we have one controller for each, and each one of these controllers has it's own Index action.
Now, technically, I KNOW you can do it either way. So this is not a question about how to technically do it. It's more about the proper practice, if keeping to a nice and hippie RESTful way.
Thoughts?
-
The "REST"ness will come from your routing not your controller if I understand you correctly.
If you mean which way should you do it in terms of the MVC programming technique, I would be tempted to create a MiscController with a "generic" or "index" method that takes an id/topic parameter and then renders a page.
This is because the action of all of these pages is the same - render some generic content.
In this way they could all use the same view, and perhaps just read the display text from a database.
If you are going to have a different view for each section I would use a different action for each section.
I tend to use a new Controller for any site "segment" or grouped functionality and an action for each possible view or exeuction action.
Pure.Krome : I agree that RESTfulness comes via routing .. but this is going to the heart of REST that each of the views above are a seperate section (or segment as u referred to) .. (and therefore should get their own controller) or are all part of the same section.
0 comments:
Post a Comment