Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Nevoic1997yMVC 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) -
Nevoic1997ySame 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.
Related Rants
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?
undefined
php
yii2
fuck logic
mvc
sideproject