ASP.NET / MVP
Nicolas Galler | May 9, 2007Trying to come up with a simple implementation of the MVP pattern. We want to minimize the fuss, minimize the deviations to standard ASP.NET, maximize testability of the presenters, minimize coupling
Scenario:
- Main entity (pool). List view, edit view.
- Sub entity (pool manager). List view, edit view, under the pool view.
- They need to be edited/saved together. Same screen, same transaction.
The views will be ASP.NET user controls (ascx files):
- Pool View
- Pool Manager View
So, there is a hierarchy of view. A pool view contains a pool manager view. There is also a hierarchy of objects, because a pool view represents a pool, and a pool manager view a manager (or list thereof). There needs to be a parallel hierarchy of presenters, right? Or should 1 presenter be responsible for doing it all? No, this would be 2 reponsibilities upon 1 class. Too much.
So, the questions are:
- Who creates the view?? They are created as ASCX controls.
- Who creates and initialize the presenters?? The top one is done from the ASPX page. The inside one must be done from the presenter, because the view can’t have a reference to it. The view can return the inner view as a property – easy to implement since its a control contained on the view.





