TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
single action per controller
  • I think " single action per controller " is better than so many action one controller.

    if under controller is directory routing and single action per controller, controller can not be fat which is most problem of MVC framework.

    if there is cons about single action per controller, could you tell me the reason

  • if under controller is directory routing and single action per controller, controller can not be fat which is most problem of MVC framework.

    What is your reasoning there? Even if you only have a single action per controller, your controller can still be fat. That is entirely dependent on your implementation.

    Personally, I'll much rather have a few more actions in one controller than have potentially hundreds of additional controllers, especially since there will be many "controllers" responsible for the same thing. It's up to you if you want to consider that a point agains your idea or not...

  • The amount of actions per controller is completely irrelevant to whether you have a 'fat' controller vs a 'slim' controller.

    You can only claim to have slim controllers if the controllers/actions do nothing but (or almost nothing but) directing information between the view and the model.

    Limiting every controller to 1 action is imho not the way to go, unless you have a very simple application.

  • what I mean is like this exsample

    Route::set('default', '(<directory>(/<controller>(/<action>)))')
    

    controller/user/edit.php controller/user/changename.php controller/user/delete.php

    default route setting is like this

    Route::set('default', '(<controller>(/<action>(/<id>)))')
    

    controller/user.php

    in this case, only one file 3 action. if one action_method has 30 lines and so on. user.php has 90 lines but if "single action per controller" there will be 3 controller files but one controller file has only 30 lines.

    this is what I mean. there for " single action per controller " is for bigger application not for simple small application.

    "Even if you only have a single action per controller, your controller can still be fat" but one controller file become slim if one controller file become slim, easier to maintain IMHO. if fat controller means amount of controller files, nothing wrong with "fat controller" for me

  • If the controller actions have a lot of code in them I suppose this approach be useful. However, I would prefer to refactor by adding view classes (if there aren't any) and/or moving more code into the models to lessen the amount of code in the controller actions.

  • If you have 30 lines of code in a controller action it is very likely that it is a fat controller. All the controller should be doing is creating classes and wiring them together.

  • thanks for reply all, my approach is similar to this URL

    http://jeffreypalermo.com/blog/the-asp-net-mvc-actioncontroller-ndash-the-controllerless-action-or-actionless-controller/

    this is what I meant.

    I didn't discuss 30 line is fat or not.

  • Is this a bit like the way in which there is only one execute method per Minion task class? If one thinks about that method as a sort of 'action', then it's just one action per controller (i.e. Task class), and the organisation of multiple tasks comes from the filesystem/class hierarchy.

  • controller with one action faster but not so usability

  • controller should not call another controller hence controller should not be usability like model. in my opinion.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion