views:

74

answers:

1

I have a layered architecture as follows;

Presentation
Service
Business
Data

If I implement MVP for the presentation my understanding is that the Service Layer represents the 'M' i.e. model, is my understanding correct? If so from my interpretation of MVP the model can raise events which my presenters would subscribe to. Does this mean that my service layer would raise events?

UPDATED

This question has been viewed a number of times but has not attracted any comments or answers, if there is something wrong with the question please comment as I would like to get an answer on this. Thanks.

A: 

The basic idea behind the View Presenter portion of a MVP design is that view is lightweight. Much of the logic that folks put into the form and controls reside in the Presenter. The Presenter is the grand central station of the design. Retrieving the data, updating the model, and raising events to let the other areas of the application know that something has changed. The model is mostly focuses on the storage and retrieval of the desired data.

The key question in using MVP design is what happens if I rip off Forms X and replace it with Forms Y? If you find yourself making radical changes to the presenter to reflect the new UI then likely it not a clean MVP design.

RS Conley
@RS Conley Thanks for responding. What you have told me makes complete sense. I just seem to get hung-up on how to deal with when a View Presenter updates the model how that change gets notified to other interested View/Presenters that may be active e.g. if I have a view that displays a list of customers which when a customer is double clicked allows editing of the customer details are we saying that the presenter for the customer editor would raise an event to broadcast that customer has been updated and other presenters would react to this event? Is this where an Event Aggregator comes in?
David
Don't think of the design as single model with multiple presenter-views hanging off of it. It is a model with a presenter with multiple view hanging off the presenter. Now internally the presenter layout can have different classes supporting each view. The presenter can also have multiple internal layers. In my CAD-CAM I have a series of UIxxx classes that support each View. Below that is a series of libraries have nothing by command using the Command Design Pattern. Below that is what I call UIForms that manages the entire UI.
RS Conley
Each UIxxx class registers itself with UIForms. The UIxxx classes then uses the various commands to manipulate the model, to draw, and most importantly for your question it can triggers command to causes other Views to the update. The update commands uses UIForms which then takes care of the update. The relationship between UIForms and the UIxxx classes uses an Observer Design Pattern. Then each UIxxx class updates the View associated with it. Just have an underlying layers that all your current presenters registers itself. Use that layer to manage the updates.
RS Conley
@RS Conley Thanks once again. From your 1st comment are you saying that the way to view things is a application will have 1 model, 1 presenter and multiple views and this single presenter will control all the views using the appropriate UIxxx class.
David