MVP model - controlling forms

  • Thread starter Thread starter Isaac Abraham
  • Start date Start date
I

Isaac Abraham

Hiya

A quick question. I'm using the MVP design pattern to write a Windows Forms
application. I understand the principle behind it and can write a presenter
that controls an associated view. The View creates the Presenter and passes
itself in to the constructor of the Presenter.

However, when I want to launch a child form as a result of e.g. a button
click - who does the responsibility lie with? It can't lie with the
Presenter because the Presenter shouldn't be closely coupled with any
particular UI implementation - and to enforce this, my Presenters are in a
separate assembly to the UI one. The UI references the Presentation assembly
and you can't reference the other way as well because of circular
dependency.

It could lie with the Form but then you start putting business logic in your
UI tier rather than your presentation tier, which I don't want to do.

Should there be a third, controlling entity which orchestrates transitions
from one screen to another?

I've Googled for this a bit and other people seem to be having the same
question - any suggestions gratefully received.

Cheers

Isaac
 
MVP is a specific pattern dedicated to the organization of data and display.
If you're intent on building the application the right way, it should
implement other patterns such as Command pattern to do these sorts of tasks.

You may find that your needs are answered by using a CAB basis for your
application which you can create ad-hoc or using the SCSF kit. This includes
implementations of MVP, Command and Dependency Injection that are common
requirements for modular and loosely coupled applications.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Bob Powell said:
MVP is a specific pattern dedicated to the organization of data and
display. If you're intent on building the application the right way, it
should implement other patterns such as Command pattern to do these sorts
of tasks.

You may find that your needs are answered by using a CAB basis for your
application which you can create ad-hoc or using the SCSF kit. This
includes implementations of MVP, Command and Dependency Injection that are
common requirements for modular and loosely coupled applications.

Bob,

Thanks for your thoughts - I'm actually using the command pattern for
exactly that i.e. tasks that one form uses initiates another command which
itself creates an instance of a form - this was my solution for decoupling
one form from the business logic of creating other forms.

We've been using the MS Smart Client factory for some of our projects (but
not the one I'm doing - I'm writing it ad-hoc) which seems to abstract a lot
of the complexity away from the developer in terms of dependency injection
etc. - but it seems like I'm on, more or less, the right track.

Thanks

Isaac
 
Back
Top