简体   繁体   中英

Should a Presenter in the Model-View-Presenter pattern handle multiple 'UI' elements on a View?

I am implementing a Diagram/Flow-Chart type designer using a Model-View-Presenter (MVP) pattern in WPF.

I have often though of this pattern (and some of the others such as Passive View and MVVM) as high level architectures that fail to address some of the complexity involved in rich UIs (here come the SO trolls).

In my particular instance, I have a UI which resembles the following mockup:

在此处输入图片说明

I have made the choice to use Presenter objects for each element which requires presentation logic on the designer. This has left me with the following designers thus far.

DesignerPresenter ControlPresenter ControlOverlayPresenter ConnectionPresenter ConnectionPointPresenter OverlayPresenter

The reason I have implemented each of these is because each of them needs to handle presentation logic and communicate its actions to the business/domain tier separately in order to avoid bloat (IMO).

The only other way I would see doing this is if there was one presenter that handles all this presentation logic which seems like it would get out of control very quickly.

My question(s) are as follows:

  1. Is it common to see presenter provided for each UI element on the screen such as I am doing in order to allow for separation of the presentation logic?
  2. Some of the presenters that are created are logically child presenters (The ControlPresenter is a child presenter of the DesignerPresenter) Is this normal?
  3. Is this in alignment with another pattern that makes more sense?

I never used the MVP but I'm really comfortable with the MVVM pattern and if I replace the word Presenter with ViewModel the design fits with what I would really do.

It is completely normal that the DesignerPresenter has an ObservableCollection of ControlPresenter and that the ControlPresenter contains an ObservableCollection of ConnectionPresenter. The ConnectionPresenter will probably have two ConnectionPointPresenter as well.

The overall design seems ok but there are probably other similar architectures that would fit too. IMHO maybe there is too much separation. Makes sense to separate a connection and the connection points?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM