Last post Aug 06, 2017 12:52 PM by Dmitry Sikorsky
Aug 05, 2017 04:34 PMfirstname.lastname@example.org|LINK
How do you decide what goes into areas, controllers and actions?
For example, /oak/leaves can either go to TreeController and Leaves("oak") action, or it can go to LeavesController and Index("oak") action.
Aug 06, 2017 12:52 PM|Dmitry Sikorsky|LINK
Good question. Usually I'm trying to make each controller to work with a signle entity or logic part. For example, if I have cats and mice, I would create 2 controllers: one to operate cats and another one to operate mice. In this case I would have the
same action names for the same actions. For example, if I need to create a cat or a mouse, the URL could be /cats/create and /mice/create. It would be not possible (or not easy) to make this with the single controller. Also, it would make it too complicated.
If we are not speaking about entities, I still would suggest to group similar actions in one controller.
What about areas. I use areas for totally separated application parts. For example, web application backend (admin part) is good candidate to be moved into an area. Some statistics module could go there too. Sometimes user profile (in large applications)
might be separated as area too.