Presenter First Design Pattern

G

Gav

I have just started to rewrite my application using the Presenter First
Design Pattern to make sure my business logic is not in the Gui itself. I've
got the general idea but I'm a bit unsure as to how I should be launching a
dialogue window from my main application window.

What i have done is this in a nutshell. My main application window comprises
of a Model, Presenter and a View. The Popup window also has a Model,
Presenter and View. This is the process of what happens when the button is
clicked is as follows.

1. Button clicked, delegate function in presenter called from main View.
2. Method in main presenter calls a method in main model to open the window.
3. Method in main model instanciates popup view, popup model and binds with
popup presenter.
4. Method in main model calls method in popup model to open the window.
5. Method in popup model uses delegate function to call method in popup
presenter.
6. Method in popup presenter calls function in popup view to display the
window.

Can anybody tell me if what I am doing sounds right?

thanks

Gav
 
G

Gav

Peter Bromberg said:
Not to be a downer on the MVP, bit that sure seems like having to go
through
a lot just to call ShowDialog.
-- Peter

It certainly is, although it did not take too long to put together. Thats
one of the reasons I'm not sure if I'm going about it in the right way.
 
K

Kevin Spencer

First, there should only be one Model, and one Presenter. The Model is the
Service (assembly) that contains all the data and business logic. The
Presenter is the class that acts as the intermediary between the UI (which
may be comprised of many UI elements, including Forms) and the Model (which
may be comprised of many logical components). The Presenter contains the UI
logic, and the Model contains the business logic. The Model therefore should
never call any methods in (have any dependencies upon) the Presenter. The
Presenter talks to interfaces that are implemented by the Model and the
View. It is these interfaces that form the "dependencies" of the Presenter.
The Presenter is the Controller of both the View and the Model, and it
manages communication between them via these interfaces that must be
implemented by the View and the Model. This way, any UI that implements the
correct interface may be used.

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top