MVC question: direct modell <-> view communication - why?
can anybody tell me, why communicates the model direct with the view in the MVC pattern, and why not jus开发者_高级运维t throught the controller?
http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller
Sometimes it is too costly to use Controller
for simple View/Model
communication.
If your view just shows raw data without any operation (filtration, visualization, modification ...) it is easy to forget about Controller.
But this behavior is so abuse-able sometimes it kills all of the advantages of MVC.
And this where MVP comes in:
MVP (Model-View-Presenter) cuts the connection between model and view and every thing pass through man-in-the-middle (Presenter).
The views know of the model and will interact with the model.
- If a button is clicked an action message might be sent to a model object in order to get something done.
- If a new value is typed into an entry field an update message might be sent to a model object in order to give it its new value.
- If a value is needed for a display an enquiry message might be sent to a model object in order to get a value.
精彩评论