Is ASP.net Model View Presenter worth the time?

Jack picture Jack · May 4, 2009 · Viewed 8.7k times · Source

I'm reading about ASP.net MVP pattern over this weekend and it seem like even the most simple task take too much effort if do it in MVP pattern the pay off seem to be at larger project but i think to myself if i'm going to follow MVP. Why not just do the project in ASP.net MVC?

The reason that I'm looking at MVP pattern is because I've noticed in all my ASP.net Webform projects there are a lot of code in the code behind just for event handling along if i have a lot of server control on the web form so i was looking at the way to reduce that and come across the MVP pattern.

Is it worth the effort to follow the MVP pattern or just switch over to the ASP.net MVC?

Answer

Ralph Willgoss picture Ralph Willgoss · May 5, 2009

I would recommend reading the following two links to get you up to speed on MVP and MVC :

Should you switch over?
Based on what you've told me I would recommend that you use the Passive MVP model mentioned in the article above.

My main assumptions are:

  1. Your dealing with an existing codebase of WebForms apps
  2. You need to use ThirdParty .Net controls for existing functionality
  3. Your working on existing apps and don't have time to re architect them
  4. Any ASP.Net Web Apps you work on in the future, you can incrementally apply the passive MVP and get the benefits of TDD straight away

Your View (codebehind + aspx) essentially become dumb and just perform simple tasks:

  • take information given by the presenter
  • responds to events and provides information back to the presenter

I've used this model extensively for Web Forms development and I couldn't imagine not being able to Unit Test my Model and Presenter code. Once you establish your base model which doesn't take very long and seen the power of Unit Testing, working with Web Forms becomes enjoyable.

Some links to MVP stuff that the model I've used is based on:

I would also recommend that you learn MVC to.
When time permits, take an existing App and port it to MVC. This way your sole focus is getting to know MVC and when you move logic into the MVC pattern, you'll discover things that you implemented in WebForms and never gave much thought to but now need to solved in another way. Great way to compare the patterns and see what works for you.

Hope this helps, feel free to ask any questions.