MVP pattern RRS feed

  • Question

  • Hi all ,

    I'm using the MVP pattern in my project. I have many views that acts with the BL through the presenter .

    My question : I used the presenter with more than one view by declaring more than interface in it (each for view). I wanted to reuse the presenter not to make presenter for each view.

    Is it rigth to do that ? Or better for seperate presenters ?


    It's very clear that this pattern separated my BL from the UI . But I still ask my self , where is the code reusing after I used it . I still declare instanse in the presenter of my BL object in each viewer witch is the same thing by using it from the UI .


    Sunday, April 15, 2007 7:27 PM

All replies

  • If you implement the MVP pattern only with a observer pattern you will only get separation of concerns and testability, when you want code-reuse you must find some overloading or some other patterns you can use with the MVP pattern, for example the command pattern and a adapter pattern, you can reuse the commands... etc etc

    Monday, April 16, 2007 6:03 AM
  • wasimf,


    Although the separation of concerns and testability that the View-Presenter pattern brings to you is a great idea, the one size fits all that you are trying to do is a bad idea.

    If you add another view, you migth have to change the presenter, which, in turn, might unnecessarily impact the other views using the same presenter.

    You should look at the pattern implemented by the Web Client Software Factory. They implemented what they called the MVPC (Model-View-Presenter-Controller). In this pattern you have a one-to-one relation between presenters and views, but each controller can be used by more than one presenter.

    Monday, April 16, 2007 8:16 AM
  • Download the article and simple sample from here

    Thank you, Regards, Srigopal

    Wednesday, October 31, 2012 11:22 AM