开发者

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.

MVC question: direct modell <-> view communication - why?

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).

MVC question: direct modell <-> view communication - why?


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜