Java – MVP: Should a View have multiple Presenters

androidArchitecturedesign-patternsjavamap

Is it desirable (from an architectural standpoint) to have more than one Presenter communicating with a View?

In my particular situation I have one presenter communicating with multiple views, and each of those views have their own presenter. In other words, each view has two presenters.

It would be feasible to use inheritance instead; in other words, having a parent presenter and child presenter.

Best Answer

The presenters job is to transform messages and data into something the view can use. It sounds like your views have two areas of concern: one unique, one duplicated.

Rather than reaching for inheritance why not let your unique presenters hold a reference to your duplicated presenter and simply reuse it? This will mean more keyboard typing than inheritance but it will keep things flexible, readable, and avoid the yo-yo problem.

Related Topic