Reputation: 1835
I keep finding conflicting information overall, nothing authoritative, and nothing specific enough to explain the exact issue that my brother and I are debating about. So can someone put this question to rest and hopefully with some authoritative-type documentation?
In short: Which of the 3 components in MVC is responsible for determining the size and location of an object to be displayed on the screen?
Upvotes: 0
Views: 82
Reputation: 5802
The key of MVC is trying to achieve loose coupling between classes. This is done by applying several patterns (MVC is a compound pattern, meaning it's a composition of several other patterns).
In here you find "Strategy between View & Controller", "Composite on View" and "Observer between Model & View/Controller".
There is a lot of debate of how it all should be handled, but the general term is this:
Something happens on view -> View informs Controller
-> Controller asks Model to change data
-> Controller asks View to update display
-> Model informs View state has changed
-> View pulls data from model
^ That's using pulling in the observer pattern which is considered "more correct", but it really is a guideline not a rule. Keeping this in mind, the View is responsible for the location of view objects (using composite pattern), and the controller is just a plugin so the actions know how to be sent to the model. This allows for easy switching between views & controllers. (Which creates bidirectional associativity but that's another story)
Upvotes: 1