9
webdev
7y

when you start a project with "im gonna do this MVC thing correctly this time" then after a few days, weeks you realise everything is a controller

am i the only one?

Comments
  • 1
    Fuck yeah true..
  • 1
    MVC is an oversimplified pattern for a full stack project. It's good at tackling subsets (i.e presentation) but overall it's not a good full pattern.

    Like in Rails, MVC is a core pattern.
    But where do I put my domain logic? Well, my domain objects of course (AR objects).
    What about my data logic? Like scoping and database retrieval abnormalities? Well, my data objects of course (AR objects).

    This breaks the SRP. Active Record objects have at least 2 responsibilities in the MVC world. I would argue more (I think some domain/application logic belongs in classes that don't hold data, i.e purely logical classes, commonly referred to as Interactors)
  • 1
    Same goes for presentation layer stuff. Generally, you should have view models (structs or decorated domain entities) to hold data, presenters for pages to simplify view logic, and your controllers to control the overall flow between gathering your viewmodels, presenters, and handing them off to your views.

    A lot of people just have a shit ton of instance variables in their controllers that try to encapsulate not only all this view logic, but some domain logic as well.

    I think that's generally how people get into the Massive View Controller problem in what was meant to be the Model View Controller pattern.

    If anyone has any questions on specifics, feel free to @ me or ping me.
Add Comment