MVP - How many presenters

痴心易碎 提交于 2019-12-10 14:49:09

问题


What is common practice, one presenter for View view and one for Edit view, or should it be all in one presenter.


回答1:


The rule of thumb which I follow is... - 1 Presenter 1 View

But for common controls you could share the presenter if the presentation logic is same... For eg... You have a Dialog control for "Confirmation dialog", "Operation Complete dialog!", and many other variants... For this I had this control realize from a common view interface and had one presenter serving the whole suite of dialog controls...

The reason is it helps to keep the pattern clean. Also, in terms of flexibility this has its own benefit..

Recently I had a task to migrate a windows application built on MVP to asp.net (1 view 1 presenter rule of thumb). The migration was seamless as I only had to worry about creating respective views rest of the things were taken care of by the design.




回答2:


I asked a similar question about WinForms, but I think the answer covers any form of MVP. The general consensus was that you should use 1 Presenter for each view.



来源:https://stackoverflow.com/questions/1444733/mvp-how-many-presenters

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