locked
MVP pattern RRS feed

  • Question

  • Hi all,

    I'm using the MVP pattern in my application . I did many views and their presenters .

    During the views building' I noticed that many fanctionalities are the same and common between the presenter.

    It's right that this pattern did the separaton between the UI and mu BL but I still think how to smarter code for resusing the code.

    I mean :

    1. How I can make common code between the presenters ?

    2. If I want to use the view in another palce, how can use it with it's presenter.

    3. Is there any recommended patterns used with this pattern ?

    4. Any links for tutorials ?

     

    Thanks in advance...

    Sunday, May 6, 2007 6:54 PM

Answers

All replies

  • I assume you googled for the specific MVP pattern and found one or two tutorials.

    Recommendations for a clean implementation of this pattern can be found in the web client software factory. This blogpost by David Hayden is a great starting point to learn more.
    Tuesday, May 8, 2007 7:49 PM
  • http://www.polymorphicpodcast.com has several podcast devoted to this subject.  I found them extremely helpful, hopefully you can also.

    Monday, May 21, 2007 8:35 PM
  • The Smart Client Software Factory uses it as well. Presenters there are implemented as classes derived from a generic (as in Presenter<T>) presenter class. This way, a lot of common code is moved to the base class. The SCSF also uses other patterns, like the command pattern, Publisher-Subscriber and others to provide a common implementation for code that would otherwise end up in the presenter.

    You should experiment with the factory that matches you project (Winforms or Web) and see how things are implemented there.

    Friday, June 1, 2007 7:26 PM
  • I have to mention the following posts from Jeremy Miller:

    http://codebetter.com/blogs/jeremy.miller/archive/tags/Build+your+own+CAB/default.aspx

    Friday, July 13, 2007 4:58 AM
  •  

     

    Wasim,

     

    Ron Jacobs did a couple of casts on MVP at ARCast (and the different sorts of patterns within that space, as defined by Martin Fowler), Polymorphicpodcasts.com also have done some that I have listened to, and should address the issues that you are facing.

     

    I'd have thought that googling this subject would give you a fairly large list of resources to read, as it's a fairly common pattern to use.

     

    Cheers,

     

    Martin.

    Thursday, July 19, 2007 1:19 AM
  • Hi wasimh

     

    1. How I can make common code between the presenters?

     

    Common domain code should reside in the model; one model can and should be used by more than one presenter so those naturally share code via there model.

     

    Common application code that cannot reside in the model -

    ·         Can sit in some helper class that is common.

    ·         Presenters can inherit common presenter that contains the common code.

    ·         One view can have more than one presenter! (MVP can, should and must be customized according to the system needs). So view can have unique presenter and common presenter.

    ·         It is important to understand that MVP does not contain definition for presenter’s and view’s hierarchy or internal structure – that is for the developer to decide.

     

    2. If I want to use the view in another palce, how can use it with it's presenter.

     

    In some cases the view create its presenter, in some the presenter create the view, in some they are created separately and the presenter is being injected to the view – as mentioned above that is for the developer to decide.

    So the answer to your question is – it depends on MVP implementation.

     

    3. iIs there any recommended patterns used with this pattern?

     

    4. Any links for tutorials ?

     

    http://aviadezra.blogspot.com/2007/07/twisting-mvp-triad-say-hello-to-mvpc.html

     

    Best regards, Aviad

     

     

    • Proposed as answer by Leonid Ganeline Wednesday, November 14, 2012 5:25 AM
    Sunday, September 30, 2007 10:42 PM
  • Download the article and simple sample from here

    http://code.msdn.microsoft.com/Design-Patterns-MVp-Model-3b691ddc


    Thank you, Regards, Srigopal

    Wednesday, October 31, 2012 11:20 AM