MVP pattern, how many views to a presenter?

北战南征 提交于 2019-11-30 09:07:21

I don't see a problem with your approach. You don't strictly need to have a one-to-many relationships between a presenter and views - usually you only have one view per presenter. The idea behind MVP is decoupling presenters from views, so that you can switch the view more easily if you need to (for example, supporting both Web application and a desktop application), but that doesn't mean you have to make it dynamic.

One suggestion: I usually supply the IView as a constructor parameter to the Presenter. The concrete implementation of IView then creates the presenter (either by hard-coded new Presenter (this) or using an IoC container to get it.

Ian Ringrose

You may find the answers to Implementing MVC with Windows Forms helpful as they talk about the different options when implementing MVC and MVP

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