Topic: How many controllers to use?
Designing the model structure of an application can be tricky, but at least one can usually rely on some fairly defined ideas on what objects/data the application should be dealing with.
However how does one decide how many controllers one needs?
The "Agile Web Development with Rails" book ends up using 3 controllers in its store example:
StoreController, AdminController and LoginController
This makes sense as in the example browsing and maintenance task/rights are clearly separated and one can see login as being a clearly separate topic...
However in the real world how does one decide what functionalities to put into a separate controller? Are there and guidelines or best practices?
For instance in an application that manages some kind of collection the browsing and admin parts can overlap as users will have the right to create new items etc. Would you still use separate controllers? Or rather would you rather try to have different controllers per each major functionality/topic/"view" that your application offers?
E.g. Using my favorite DVD collection example, would you have one controller for browsing collections, one for browsing/editing actors etc.? (But not one controller per model...)
Last edited by bjavor (2007-01-11 08:19:08)