epitka
epitka

Reputation: 17627

MVP - How many presenters

What is common practice, one presenter for View view and one for Edit view, or should it be all in one presenter.

Upvotes: 5

Views: 1022

Answers (2)

SwDevMan81
SwDevMan81

Reputation: 49978

I asked a similar question about WinForms, but I think the answer covers any form of MVP. The general consensus was that you should use 1 Presenter for each view.

Upvotes: 3

rajesh pillai
rajesh pillai

Reputation: 8118

The rule of thumb which I follow is... - 1 Presenter 1 View

But for common controls you could share the presenter if the presentation logic is same... For eg... You have a Dialog control for "Confirmation dialog", "Operation Complete dialog!", and many other variants... For this I had this control realize from a common view interface and had one presenter serving the whole suite of dialog controls...

The reason is it helps to keep the pattern clean. Also, in terms of flexibility this has its own benefit..

Recently I had a task to migrate a windows application built on MVP to asp.net (1 view 1 presenter rule of thumb). The migration was seamless as I only had to worry about creating respective views rest of the things were taken care of by the design.

Upvotes: 5

Related Questions