Model View Presenter nesting
Asked Answered
G

0

12

I've run into a scenario which requires nesting of the MVP pattern. It is probably best to explain using a visual example:

------------------------------
| [View]                     |
|   |                        |
|   +----[Presenter]         |
|             |              |
|             +------[Model] |
|____________________________|
            |
            +----[View]
                   |
                   +----[Presenter]
                             |
                             +------[Model]

This is how the two MVP layers should interact. My question is in regards to the connection between the two. I can envision several ways to connect the two:

  • The Presenter from Tier 1 is connected to the View for Tier 2.
  • The Model from Tier 1 is connected to the View for Tier 2.
  • The View for Tier 2 IS the Tier 1 (the View contains references to the M, V, & P of Tier 1).
  • The Presenter or Model from Tier 1 IS the View for Tier 2.

Which of these is correct, if any?

Then there is the question of HOW they are connected. Should the Tier 2 View have a reference to one of the objects from Tier 1? Should the interaction be purely event based? A combination of the two (if so, where should the reference lie?)?

I'm pretty new to using these types of patterns, so any insight would be appreciated.

Gummy answered 25/11, 2013 at 16:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.