官术网_书友最值得收藏!

The Model-View-Presenter pattern

Model-View-Presenter is a variation of the original MVC pattern that we discussed previously. Both MVC and MVP target the separation of concerns but they are different on many fundamental aspects. The presenter in MVP has the necessary logic for the view. Any invocation from the view gets delegated to the presenter. The presenter also observes the model and updates the views when the model updates. Many authors take the view that because the presenter binds the model with views, it also performs the role of a traditional controller. There are various implementations of MVP and there are no frameworks that offer classical MVP out of the box. In implementations of MVP, the following are the primary differences that separate MVP from MVC:

  • The view has no reference to the model
  • The presenter has a reference to the model and is responsible for updating the view when the model changes

MVP is generally implemented in two flavors:

  • Passive view: The view is as na?ve as possible and all the business logic is within the presenter. For example, a plain Handlebars template can be seen as a passive view.
  • Supervising controller: Views mostly contain declarative logic. A presenter takes over when the simple declarative logic in the view is insufficient.

The following figure depicts MVP architecture:

主站蜘蛛池模板: 胶南市| 彰武县| 泾阳县| 甘肃省| 兰西县| 通山县| 长宁区| 剑阁县| 庐江县| 遵义县| 杭锦后旗| 新和县| 卢氏县| 五家渠市| 晋中市| 城口县| 霍城县| 体育| 尚义县| 时尚| 碌曲县| 赤城县| 无为县| 石狮市| 曲阜市| 慈利县| 弋阳县| 奉新县| 海林市| 固镇县| 广德县| 延吉市| 娄烦县| 大荔县| 灌南县| 昆明市| 禹州市| 长子县| 玉溪市| 福州市| 怀集县|