Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I currently use one controller per action. One of the problems—sort of—I encountered is when naming the methods of these controllers, which only have one.
Should I use a generic method name like get() or should I encapsulate all my controllers into one and name its methods after the action they do, e.g. indexAction(), userListAction()?

share|improve this question
up vote 4 down vote accepted

I like the Ruby on Rails "RESTful routes" convention: each controller represents a resource (a noun), and there are 7 conventional actions:

table from Ruby on Rails routing guide

Note that resources don't have to map directly to models/database tables - for e.g. password reset, you may "create" a password_reset resource to request a new password, and "update" it to set the new password, even though behind the scenes, it only modifies your user model.

share|improve this answer
Thanks a lot! Really helpful. – seriousdev Jun 19 '11 at 9:59

I would not combine all the controllers into one. It is easier to manage lots of small classes than one great big one. This is particularly true when there are multiple developers. For method naming, it doesn't matter much, but you may want to use different names for "GET" and "POST" requests, like "get" and "post". Usually there are standard practices for a given web framework.

share|improve this answer

Your Answer


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.