协调 MVP 三合会
假设您的应用程序(WinForms .NET 2.0 应用程序)中有多个 MVP 三元组,每个三元组负责一个职责领域。您协调 MVP 三人组之间沟通的首选方式是什么?
选项1 协调器对象“拥有”每个模型,并通过订阅每个模型中的必要事件来负责协调,然后决定在什么情况下调用什么模型方法。
担心这可能是一门“神”课。
选项2 演示者“拥有”另一个演示者,当模型中发生感兴趣的事情时,演示者会使用另一个演示者来推动通信。
担心演示者不应该有公共界面(演示者优先的方法),这打破了这一点。
我只是想知道其他人做了什么来以可扩展的面向对象方式解决这个问题。如果我添加另一个 MVP 三合会会怎样?将其融入我的协调器有多难?一定有一些很好的例子来说明如何在 WinForms 应用程序中管理多个 MVP 三元组?
Say you have multiple MVP triads in your application (WinForms .NET 2.0 app) and each triad looks after one area of responsibility. What is your preferred way of coordinating the communication between the MVP triads?
Option 1
A coordinator object that "has" each model and looks after the coordination through subscribing to the necessary events in each and then deciding what model methods to call in what scenarios.
Worry that this may be a "god" class.
Option 2
A Presenter "has" another presenter and when something of interest happens in the model, the presenter uses the other presenter to move communication along.
Worry that the presenters should not have a public interface (Presenter-first approach) and this breaks that.
I am just wondering what other people have done to solve this problem in a scalable OO fashion. What if I add another MVP triad? How hard will it be to fit that into my coordinator? There must be some good examples of how to manage multiple MVP triads in a WinForms app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要含糊...但这取决于情况。我过去使用过的两种方法:
events.Raise()
和 PresenterB 实现:IHandler
并在其public void Handle (MyEvent @event)
方法中做出相应反应。界面:
Not to be vague... but it depends. The two approaches I've used in the past:
events.Raise<MyEvent> ()
and PresenterB implements:IHandler<MyEvent>
and reacts accordingly in itspublic void Handle (MyEvent @event)
method.The interface: