Model / performance / presenter: the relationship between presenters and presenters

I have a presentation class that represents a widget and companion presenter class. I also have a view class for a window that has a widget, and an accompanying presenter for the window. A window controls widgets, so I need the window presenter to communicate with the widget presenter. To visualize:

+-------------+ +------------------+ | widget_view |<------>| widget_presenter | +-------------+ +------------------+ ^ ^ | | | V +-------------+ +------------------+ | window_view |<------>| window_presenter | +-------------+ +------------------+ 

I am not sure how to build objects. I know that MVP architecture does not address this problem, but "leaves it as an exercise for the reader." Things I tried:

  • Views build their presenters, and window_view builds widget_view . But then window_view needs additional parameters in its constructors, parameters that it should not care about, just to create an instance of the master. I also don't know how window_presenter will access widget_presenter . Adding the widget_presenter installer to window_presenter for window_view to populate doesn't look like me.
  • Remove the link between the two hosts. window_presenter talks to widget_presenter through window_view . This also does not seem ideal for me, because to add window_view window_presenter widget_presenter . , widget_view , . window_view window_presenter widget_presenter . , widget_view , .

I can imagine that complexity growing exponentially here, like window_presenter , should talk to other presenters, or other presenters should talk to other presenters.

I also thought about adding a mediator object here to absorb all these connections and dependencies, but at the moment the whole idea of ​​the logic branch from the presentation is starting to feel very expensive and very difficult. Of course I'm doing something wrong.

+4
source share
1 answer

I found this article that could help:

http://martinfowler.com/eaaDev/uiArchs.html

In particular, it looks like you're talking about a “classic” mvc, where each widget is a view with its own controller. I think that the article refers to a “formal” view of the world, each “form” is a set of views, and there is only one dispatcher or leader. I think MVP falls under the "form" view, so there is usually one lead to the form.

0
source

Source: https://habr.com/ru/post/1415475/


All Articles