locked
MVP Pattern for webforms RRS feed

  • Question

  • User37182867 posted

    I know this is an older design pattern and it looks very interesting to me. I was just curious if any of you have any experience with it or have any idea of its actual popularity.

    Tuesday, January 20, 2015 3:11 PM

Answers

  • User-821857111 posted

    I think the deafening silence should tell you that it is not a particularly popular pattern among Web Forms developers, mainly because those who use Web Forms tend to stick with the Page Controller pattern that ASP.NET Web Forms is based on. I've been visiting these forums for about 8 years or so and read tens of thousands of posts. Yours is about the second or third question I remember seeing about MVP in ASP.NET.

    There is a Web Forms MVP framework that was developed by Tathum Oddie and Damian Edwards (who currently works for  MS on the ASP.NET team) which appears to have had about 20k downloads. That seems a small number to me. The Html Agility Pack has had nearly 250k downloads, for example. 

    If you are after the kind of separation that MVP will give you, I'd say just go with ASP.NET MVC. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 21, 2015 6:04 AM
  • User-1611549905 posted

    Having used the MVP pattern on a WebForms project a few years back, I'd concur with what Mike's said here.

    The intention of the MVP pattern is to make WebForms-based applications more testable by giving you an abstraction layer around the WebForms page controller pattern, which you can then mock in your unit tests. However, I found it a pretty cumbersome pattern to implement, requiring quite a lot of boilerplate code, and in practice all we ended up unit testing with it was the MVP pattern itself. Personally I thought it was a lot of overhead for a very self-serving pattern whose only purpose seemed to be to pacify the kind of people who moan if you aren't Sticking To Best Practices™.

    If you need that level of testing in a WebForms application, you're probably better off using end-to-end browser-based tests with Selenium. People who are serious about unit testing and TDD tend to avoid WebForms anyway, and stick to frameworks such as MVC that have more extensibility points and better pluggability built in to the framework itself.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 21, 2015 7:37 AM

All replies

  • User-821857111 posted

    I think the deafening silence should tell you that it is not a particularly popular pattern among Web Forms developers, mainly because those who use Web Forms tend to stick with the Page Controller pattern that ASP.NET Web Forms is based on. I've been visiting these forums for about 8 years or so and read tens of thousands of posts. Yours is about the second or third question I remember seeing about MVP in ASP.NET.

    There is a Web Forms MVP framework that was developed by Tathum Oddie and Damian Edwards (who currently works for  MS on the ASP.NET team) which appears to have had about 20k downloads. That seems a small number to me. The Html Agility Pack has had nearly 250k downloads, for example. 

    If you are after the kind of separation that MVP will give you, I'd say just go with ASP.NET MVC. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 21, 2015 6:04 AM
  • User-1611549905 posted

    Having used the MVP pattern on a WebForms project a few years back, I'd concur with what Mike's said here.

    The intention of the MVP pattern is to make WebForms-based applications more testable by giving you an abstraction layer around the WebForms page controller pattern, which you can then mock in your unit tests. However, I found it a pretty cumbersome pattern to implement, requiring quite a lot of boilerplate code, and in practice all we ended up unit testing with it was the MVP pattern itself. Personally I thought it was a lot of overhead for a very self-serving pattern whose only purpose seemed to be to pacify the kind of people who moan if you aren't Sticking To Best Practices™.

    If you need that level of testing in a WebForms application, you're probably better off using end-to-end browser-based tests with Selenium. People who are serious about unit testing and TDD tend to avoid WebForms anyway, and stick to frameworks such as MVC that have more extensibility points and better pluggability built in to the framework itself.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 21, 2015 7:37 AM
  • User37182867 posted

    Thanks for your input guys, I was thinking that this was the case when I went to search for the pattern and found 0 books written on it and only a hand full of pages describing it. I did find the nuget package and saw exactly what you mentioned about it being very lightly downloaded. 

    Wednesday, January 21, 2015 10:38 AM