What is the difference between controller in MVC pattern and presenter in MVP pattern?

杀马特。学长 韩版系。学妹 提交于 2019-11-30 02:06:32

In MVP the Presenter assumes the functionality of the "middle-man" (played by the Application Controller in MVC). Additionally, the View is responsible for handling the UI events (like mouseDown, keyDown, etc), which used to be the Controller's job. Eventually, the Model becomes strictly a Domain Model.

Says Wikipedia.

Here is a more detailed explanation on the differences between the two.

See also Martin Fowler's Retirement note for Model View Presenter.

In MVC, the view is updated only by the model (by listening to its events). It is never updated by the controller. This is problematic when you need to format model data for the view, hence the need for MVP.

In MVP-Passive View, the view is updated only by presenter (presenter sets view properties). The presenter listens to events on the model [modifying the data if required] prior to updating the view.

In MVP-Supervising Controller, the view is updated by either the model or the presenter. If no formatting is required, the view updates itself via the model. If formatting is required, it updates itself via the presenter.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!