MVP Design Patterns – Communication Between Multiple Presenters in MVP

Architecturedesign-patternsenterprise-architecturemvp

I'm designing an application using the MVP pattern, but a few of the edge cases for the system rely on communication between multiple presenters.

View 1 calls Presenter 1 which does Operation A returning Result X.

View 2, View 3, and View 4 are all interested in Result X. They each have their respective presenters, and can each respectively do Operation A and get Result X.

Our application has a MainView and a MainPresenter which effectively just house the other views and presenters.

One of the solutions was to give the MainPresenter references of Presenter 1, Presenter 2, Presenter 3, and Presenter 4. And having the result of Operation A call the other presenters.

Another was to implement a Facade layer that holds references to other presenters and it facilitates the other calls.

How have you handled this situation?

Best Answer

In my experience, if a result is needed in multiple places in the user interface, this suggests to me that the method for calculating it is a universal business rule, and therefore that rule has no business being implemented in a single presenter: it should be part of the domain model, instead. At that point, no communication between presenters is needed, other than that they all reference the same domain model.