I Spose I’ll Just Say It: You Should Learn MVC

I’m never shy about my opinion – why start now? I’ve been reading a lot of posts flying about on whether you should learn MVC, Summing up the differences so you can decide when to use it, I even found a post that offers a scorecard approach! I remember reading the latter post thinking to myself “how can you possibly put a number next to Testability? And why it is only 2 more points than “using a RAD designer”? Isn’t this missing the entire point?

I felt the need to speak up a bit so I left a comment on DotNetKicks:

Please don’t use this “scoring” chart with respect to MVC and WebForms. Honestly – you can’t “score” something like “should I care about Testability” (which rates an 8) against “do I need to use this Server Control” (which scores a 10).  There are so many problems with approaches like this – really the only answer is to *try it* and see if it works for you or your org.

Today I read a post on StackOverflow which was pretty contentious wherein the author says:

I’ve been fiddling with ASP.NET MVC since the CTP, and I like a lot of things they did, but there are things I just don’t get…

<snipped ugly viewcode>

Am I doing something wrong? Because I spent many dark days in classic ASP, and this tag soup reminds me strongly of it.

Everyone preaches how you can do cleaner HTML. Guess, what? 1% of all people look at the outputted HTML. To me, I don’t care if Webforms messes up my indentation in the rendered HTML, as long as I have code that is easy to maintain…This is not!

I have definite opinions on this, and today you get to read them. Note that I pushed Scott Hanselman really hard when we wrote our book (which I think is shipping today!) to come out AND SAY SOMETHING (Chapter 3 – a discussion on MVC and WebForms – and he did an amazingly good job). It’s too easy to think “hey – I’m Microsoft – I need to stay balanced here so I don’t offend” and there’s merit to that.

I, on the other hand, think we should also be able to speak our minds. In that light, I present to you my latest effort at getting in trouble: why you need to read this post, get up, and learn what MVC is all about (if you don’t already know).

The Great Lie
WebForms is a lie. It’s abstraction wrapped in deception covered in lie sauce presented on a plate full of diversion and sleight of hand. Nothing you do with Webforms has anything to do with the web – you let it do the work for you.

This, friends, is a big deal (at least to me): You’re working in a lie. The web is *not* stateful and works with this stuff called HTML sent across wires using another thing called HTTP – you need to know this, love this, and feel it at the bone level. I understand this sentence right here is probably making some of you squirm – please continue squirming (I’ll wait). world

If you’re still squirming, then perhaps web development isn’t for you (meant very respectfully and kindly – not being snarky). I say this because you shouldn’t work in a sausage factory if you’re allergic to pork, beef, and ground up animal parts. Nor should you put a wig on your cat and hope that it can sing like Susan Boyle.

These are self-deceptions put in place to make you feel better about something lacking, and it’s usually not healthy. If you’re thinking that you don’t need to know HTTP/HTML to work on the web… you’re doing it again! Please see 2 sentences ago.

If you’re still thinking it – your cat needs a new wig.

MVC Is Elite-test?
I’m sure that WebForms people are probably thinking I’m being a bit of a sh** right now – and I’d like to speak to that. The title of the post here is “You Should Learn MVC” – not that you have to use it (although I wish you would – it’s tons of fun!). That’s all I’m asking – for you to learn it; I’m not telling you that you’re a bad person if you don’t use it (only that you put wigs on your cat).

MVC Is Full of Tag Soup?
Once again, I’ll say this: Spaghetti is as Spaghetti does. I don’t like to see a bunch of if’s and fors on my View the same as any other geek. This, friends, is up to you! Not the platform! Please read this: markup is up to you, as with everything else in MVC. Yes it’s not drag and drop – but nothing ever is in life! It’s new, it’s different – it’s not 1999 if only because we have the power of C# now – not VBScript.

I’m not afraid of HTML – and you shouldn’t be either. Respect it when putting code to page and use DRY as your guide. We can make it through this, together. You can bring your cat, too.

7 Reasons To Stop Calling Me A Jerk
Hopefully you’re still here, and hopefully you’re thinking “enough of the blather already – gimme something to sink my teeth into”. So here goes:

1 – Testability. No – not talking about the TDD variety, just testing in general. If you’re “not a testing person” that’s OK – the rest of the computer science world has embraced the idea that “testing what we build is a pretty good idea”. You don’t really want your clients to catch that silly “InvalidCastException” do ya? There’s LOTS of reasons to want to test – again not TDD – just good old Unit Testing! It’s easy peasy with MVC and this alone should pull you in to at least check it out – along with why testing can save you time and money.

2 – Control over HTML. I’m sure you’ve heard this before – mangled ID’s, non-validating HTML, etc. Why is this important? Because you might want to use client-side programming for something! I won’t bang this gong for too long – but it’s a lot more than “making ViewSource look pretty” – you’re communicating with super-finicky creatures (browsers) that love to argue – being able to smith the markup experience makes you a more valuable developer!

3 – Extensibility. Literally every part of MVC Is pluggable – and in the last 3 apps I wrote (Storefront, Nerddinner, and SubSonic’s MVC Starter) I used my own ViewEngine to save some time and work. I’ve spun up my own ControllerFactory so I can use IoC (which is awesome fun!) Understanding this is the keys to the kingdom for any developer! Have you ever been freaked out because you needed to use Page_PreRender to get something to load into the ControlTree properly so it will show when you need it to? MVC does not lock you into anything – you’re free to do what you want to.

4 – It Makes You Think… This is the one thing I never liked about WebForms – I never felt like I was thinking – just solving. May seem like splitting hairs, but not to me. I’d get a bit of inspiration and then try to figure out “hmmm – how can I make the form show it this way”. MVC is the opposite – the control is in your hands and you get to be free with it. You get to use your noggin! Wow!

5 – …Differently: Javascript Doesn’t Suck. jQuery, Dojo, extJS – whatever. These frameworks make client development so easy it’s actually fun. Phil and I have recently geeked out extensively using jQuery (he more than me) and I distinctly had the feeling that I’ve been missing something. Something that other platforms have had for years – the ability to make a web experience fun and magical (for a user) through client programming. It makes you think completely differently once you “get it” – and soon your server code is being drastically reduced in favor of light, clean client code (thanks to these frameworks) that work up an awesome experience. Cats love jQuery too.

It may seem weird to say it, but developers like to learn a language every few years – make javascript the one you learn this year. You might think you know it, but you probably don’t know it as well as something like C#/VB. Try to – it will change your development entirely from scheming out an interaction to how much code you write.

6 – Learning New Concepts. You’ve seen them everywhere, and seen us fighting about them. We probably shouldn’t argue so much :) but in a way, this is part of the learning process! Either way – take it upon yourself to learn some things. WebForms is a comfy blanket that can lull you to sleep over time. This has happened to a lot of us (myself included). We’re only now catching up with frameworks that have been creating rocking, compelling sites over the last few years – jog your brain! Wake yourself up and get to know the details that make compelling sites groovy! Learn the things that can help you write more nimble code – if only so you can argue from a point of knowledge!

7 – It’s Fun. This, to me, is the biggest reason. I find MVC fun because I can do what I want, when I want, how I want. I’m free to build an experience that I feel will sell my design, and I’m not hindered by a A Big Lie and a freaky cat with a wig on.

Bottom line: I’m having fun web programming again and I think that’s pretty motivating, at least for me and my cats. Yet Another Comparison, sure, but hopefully a bit more direct. You have absolutely no reason at all to not learn MVC – but I will concede there may be a reason or two for you to stick with WebForms.

I know many people might think I’m speaking for the rest of Microsoft – hardly. I’m biased and, more importantly, I actually still have my very own brain which forms its own thoughts! I love MVC and I think you will too – just please, please try it before you form an opinion.

This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

11 Responses to I Spose I’ll Just Say It: You Should Learn MVC

  1. Srikar says:

    Hey Rob,

    This is an awesome article. I have been challenging everybody over at stack overflow and my friends to try ASP.NET MVC before they write it off based on somebody’s comments (which get scored high for some reason) or a scoring system created by somebody who did not even try using ASP.NET MVC in the first place.

    I really like the emphasis on JQuery. For too long, we have been missing out on good client programming frameworks and techniques.

    As I tell everyone, the new age of Microsoft has just begun and this time it is evolving to simply the best platform ever.

  2. Rob Conery says:

    Hey David! I’d love to come – it’s all about the $$ unfortunately and I don’t have the wherewithall to foot it myself :(.

  3. Kyle Nunery says:

    The other big thing it does is enable AJAX usage in a much better fashion. Say I want to load data for my super cool tooltip on my customer table… Using webforms you can use PageMethods or a WebMethod from client script. With the MVC framework it is much easier to get a JSON result for a one off method meant to be used on a single page. This is one area that sells me on MVC as I continue to do more client side scripting to give customers features that they now expect in web applications.

  4. David Hayden says:


    How do I get you to come out to Tampa, Florida and speak to the Tampa MVC Developer Group? I am serious. I need you there to help spread the message.


  5. rball says:

    The thing that I love about MVC is the freedom to do anything. I’m working on two projects right now at the same time, one webforms and one mvc. Both are using jQuery. The problem begins with webforms when you start to take away controls like the “Grid” because you don’t like them. Once you start using repeaters you are essentially overriding all the good that a certain control gives you. The problem with controls though is that they lock you in to doing exactly what the control was meant to do without much leeway. I use repeaters where I can, but even without jQuery, javascript itself is a huge pain webforms. If you like that pain, then more power to ya.

    The other thing is that now I feel like I’m part of a bigger community. Instead of the small subset of “How can I do this with ASP.NET?” I’m asking “How can I do this?” and I don’t even have to mention what server side technology I’m working with. It’s pretty great that I can now take a PHP solution and just fit it right into my own stuff and I just keep on chugging.

    Oh, and testing? Are you kidding me? With web forms at best you had Watir, Watin, or Selenium to test the UI. Now I can have a fully 100% covered controller/service/repository that tells me that everything I’ve tested for is working. The amount of confidence over “is this page working right” has grown a ton. I’ll still be using the “Acceptance” testing tools but now I’m able to unit test quickly with each build. That level of testability just isn’t there for webforms.

    Again…even with a small website it will either grow or die. If it’s gonna grow then you’d want to make sure it works – testing. Then you want the flexibility to do things in any way you can imagine – sure go for it with repeaters and I’ll do it 5x faster with just plain html. Then throw in scripting and I’m just kicking your (or my own) ass all over. 😛

  6. Travis says:

    I cringe at the tag soup, but more and more I am finding ways around it as I learn the MVC approach. Good post.

  7. @Joshua – Yeah, totally use JQuery all the time. Love it! Yes, the id mangling in Asp tags can be a bit of an annoyance, but the workarounds are pretty easy.


    Also, all your tags do not have to be runat=”server” . To be honest, I very rarely need to directly target a server tag. Once again, it comes to making wise decisions concerning your forms. Do all your links really need to be asp:Hyperlinks? Do you really need that gridview (which I hate) or can you be much more fluid using a simple repeater? Do you have to make a button w/ postback or are you updating the page w/ Ajax instead?

    So, I still stand by the fact that they are “100% as easily accessible”. Sometimes it does come to knowing what the limitations and workaround are, but it is the same w/ anything else. Once you know them, they should no longer be a barrier.

    Finally, my intention is not to say x is better than y. There is no such thing as the perfect approach to anything. My intention is to give credit where credit it due and not to fall into the same trap that @Paul was referencing earlier.

  8. Nathan – have you tried to use jQuery or other client framework with webforms? I know it would seem like all you have to do is reference the .js file, and everything is the same – until you actually try it.
    In jQuery, you interact with your web page using “selectors” which identify pieces of markup on your page. When targeting a specific tag on your page (a button tag which you want to add a click event handler for), the easiest selector to use is the id. When you create a button in webforms, using asp:button, you do not know what the client id of that button will be – so how can you write client script to reliably reference it?
    There ARE tricks you can do to write out the client ids using server side markup. But at that point, you can no longer claim that webforms makes it “100% as easily accessible”

  9. Okay, I find myself posting on these MVC vs WebForms posts way too much of late. I was in complete agreemnet w/ you for much of your post. We should check out MVC. It has some pretty sweet things to offer. However (I think that you agree with this), there are no silver bullets and. often times. different situations call for different technologies, even though there is quite a bit of ovelap between MVC and WebForm’s usability.

    The parts that drive me crazy… Every post like this feels compelled to make an ordered list of why MVC rocks, much as you have done. However, I am always appaled by the fact that Testibility and JQuery (and other JS frameworks) makes it on the MVC Rocks list as if WebForms do not offer these features in the same depth.

    JQuery and other javascript frameworks are 100% as easily accessible for Webforms as they are for MVC. Its just a referecne to a Javascript file. For WebForms, you download it, add reference, and you are good to go.

    Also, if you are writing Web Forms that are not testable – you are doing it wrong! The only point that MVC has over Web Forms in this regard is UI testing, which I usually do not bother with anyway (please reserve your collective gasp, lol). Your code-behind pages should really only include binding logic or data capture logic. Gerernally speaking, I find it a bit drastic to write unit tests to ensure that my repeater is working properly.

    Extensibilty – Once again, if you are writing applications that are not pluggable – you are doing it wrong. Use of Web Controls, Compliled DLLs, etc give you this ability.

    IMHO, the biggest problem with WebForms is that it has low barrier of entry. Thus, people can start with them very easily and begin to establish bad coding practices. MVC is slight less fluid in this aspect, when tends to force you into better coding practices.

    Anyway, try out MVC. It is a great tool. I like it. I also like WebForms and find that I am able to create rockin’ and maintainable apps in both.

  10. Paul Cowan says:

    I prefer these type of posts instead of:






    As soon as you start stating should or must then you are onto a loser.

  11. In my opinion, learning about the MVC pattern / framework is something every web developer needs to do. Personally I find MVC really liberating after using webforms for so long. Right now I’m working on three official projects, two webforms, one MVC, and the contrast between the two frameworks is thrown into sharp focus on a daily basis for me. I really enjoy the time I spend working on the MVC project. I’ve been using ASP.NET MVC since the CTP/Preview versions, so it’s not that I’m enjoying it more simply because it’s something ‘new’. It’s just a much more natural way to write web applications in my opinion. I don’t need to pretend I’m writing windows applications when I’m writing web apps – the whole event driven architecture for webforms was an ‘interesting experiment’ but it never really felt right.

    You don’t actually say you should learn ‘microsoft’s official ASP.NET MVC’ here Rob, which is interesting, although I’m sure that 99% of web forms developers starting out with MVC will be using the Microsoft flavour. I would say it’s worth looking at alternatives such as fubu mvc (the highlander principle is worth understanding even if you don’t use fubu mvc or the highlander principle!) and Rails. There’s a lot that can be learned from those ‘opinionated’ implementations of MVC even for the majority of developers who are destined to end up using microsofts officially sanctioned (and less opinionated) version.

Leave a Reply