Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Say I have 2 controllers, OrderController and StatusController. OrderController has several CRUD actions for Orders and StatusController has several actions pertinent to changing the satus of Orders (from created to sent, cancelled, etc).

StatusController really only has one view where several actions can be performed, but for the sake of usability I've decided to merge the functionality of this one view with the Index action of OrdersController. (This is just an adapted example for the question, so bear with me if it sounds silly).

Only by copy/pasting the Html in the views from here to there everything works, of course, but...

What should I do with the actions on StatusController? Should I move them to OrderController or Should I let StatusController exist even though it has no views? I think it might be better than having OrderController have 15 actions, but is this desirable? Is there a recommended good practice/approach in such case?

share|improve this question
    
Do the methods in the StatusController return ActionResults that use views under the OrdersController views folder? –  Mike Mar 23 '11 at 16:15
    
@Mike - No, they don't. They were originally written as 2 separate sections, so no dependencies there. Besides, after the "merge", actions in StatusController are only used in Ajax calls returning Json results –  Sergi Papaseit Mar 23 '11 at 16:20
add comment

migrated from stackoverflow.com Mar 23 '11 at 15:35

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 4 down vote accepted

Based on your comment above to my question where you stated that the Status controller is only used for AJAX calls currently I would still leave it separate from the Orders controller.

The MVC idea is that the controller acts like a traffic cop for incoming requests and determining the out going responses. Even though you aren't returning a view per say you still have Status specific requests (via AJAX) and responses (via JSON) to the web server which warrants a seperation.

Perhaps to keep the naming more concise you could rename the Status controller to OrderStatusController since it sounds like it acts purely on status for the orders.

share|improve this answer
    
Thanks, that makes sense –  Sergi Papaseit Mar 23 '11 at 16:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.