Hanalei, Hawaii 9/2/2010
438 Posts and Counting

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

Wednesday, April 22, 2009 -

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.

Summary
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.

Related


Gravatar
Issa_Qandil - Wednesday, April 22, 2009 - Hey Rob, Its the first time i leave a comment on your blog, but this post is just like a BOMB, Thanks for sharing some of your thoughts. Hope i will be able to read your book soon. Regards,
Gravatar
Chris Pietschmann - Wednesday, April 22, 2009 - Yes, I agree, every ASP.NET developer should at least learn the basics of ASP.NET MVC; whether you use it on your next project or not. However, there's something to be said about the fact that it really complex and reminds us all of "Classic ASP". Remember the days when we all transitioned from Classic ASP to ASP.NET; it looked too complex and had a much steeper learning curve than Classic ASP. Well, ASP.NET MVC is similar, except the fact that if you're coming from ASP.NET WebForms, then you already know a ton of what you'll use with ASP.NET MVC. Plus, JavaScript really isn't that bad, and you even have frameworks like jQuery and ASP.NET AJAX to help take the load off. I do however have one negative thing to say about ASP.NET MVC... It feels like I'm re-inventing the wheel with everything!! Well, the reason for this is it's so new still. ASP.NET WebForms is really mature compared to ASP.NET MVC. However, I don't think ASP.NET MVC will take 7 years to get to the maturing of ASP.NET WebForms; after all it's still based on ASP.NET and you can't forget about jQuery and ALL the plugins!
Gravatar
Rick Dailey - Thursday, April 23, 2009 - I can't agree with you more (I tried). Using WebForms for HTML/HTTP is like driving a car from the roof: http://www.youtube.com/watch?v=A8KX_WdEu4E Something you might want to mention is SEO and analytics. I'm talking about Google here, but other systems are all just trying to play catchup, so yeah. Also, no one knows for sure, but the prevailing wisdom as I understand it is: ViewState - Bloated, right at the top of the page - the farther down the page the content is, the less relevant Google considers it. Keyword rich urls - Google loves these, and they're (mostly) free in MVC Content hidden behind form posts, javascript, redirects - Google will not index. At all. You're throwing away perfectly good pages of content Clean, lean html - There's some evidence to suggest that properly marked up content will get higher relevance Also worth noting; clean html means better performance for your users, especially mobile users. This translates directly into retention.
Gravatar
robconery - Thursday, April 23, 2009 - Awesome feedback - thanks Rich!
Gravatar
Kevin Pang - Thursday, April 23, 2009 - I think you may have mischaracterized my post in the process. My post was about whether you should *use* ASP.NET MVC, not whether you should learn it. :-) Other than that, great post and I agree 100%. Like I wrote in my post, it never hurts to look at how you're approaching development from another angle. Thanks to people like you, the learning process for ASP.NET MVC contains all sorts of goodies along the way. That alone is worth at least looking into it, if not using it.
Gravatar
Bertrand Le Roy - Thursday, April 23, 2009 - I absolutely *love* the (voluntary?) typo on "elitest". Beautiful. Your subconscious is so right on that one.
Gravatar
huey - Thursday, April 23, 2009 - I love C# but hate WebForms. Every day at work I am thankful that MVC lets me use C# and develop web applications. I do agree that a lot of times you feel like reinventing the wheel with every app, but I put that as much to MVC being young as it is to always learning new development ideas that are more commonly ignored. I had this idea when I first started to kind of get in a groove where I have figured out 'my style' and can just pop out app after app. Instead when I start the next app I think about ways to improve it from the first due to some new ideas in a blog post. Oh well!
Gravatar
John Sedlak - Thursday, April 23, 2009 - I had been really putting off ASP.NET MVC because in general I do not agree with the design pattern itself. Recently I have given up on finding and working with third party content management systems and decided that I needed to build one from the ground up using all the new technologies available (at this point I already invested a few months on a nice service layer in WCF). To make a long story short I am now in MVC up to my knees and loving it! It is taking some time to learn but I am so glad that I do not have to deal with WebForms anymore and rather can just focus on adding features and content.
Gravatar
John - Thursday, April 23, 2009 - I quickly learned how "simple" web forms are (or rather aren't) when I first started doing .Net programming. I wanted to do 3 things that I thought should be simple: 1) I wanted the gridview row to be highlighted when I hovered over it. 2) I wanted to be able to click on a row to Select it and not have to click Select. 3) I wanted to be able to dynamically change the highlight color. Suddenly, web forms weren't so simple. I had to learn about the pipeline and how the gridview events work. Next, I had to learn about Javascript anyway as that was the only way to do cross-browser hover (IE6 and before only supported CSS hover on the anchor tag). And for 3), I had to learn how to write the Javascript color value that I needed in the code behind. It all worked, but all of a sudden, it's not clear where to look when you want to know where a simple thing like highlight color is coming from -- it was in the codebehind, which, intuitively, was the 4th place to look after the aspx, css and js pages. And I hadn't even learned about separation of concerns, testability, or good O-O design yet! I have high hopes for MVC.
Gravatar
LukeB - Thursday, April 23, 2009 - It's pretty simple, if you don't know HTML and HTTP in and out, you are not a web developer.
Gravatar
Justin Etheredge - Thursday, April 23, 2009 - Your comment about having fun programming for the web again cannot be understated. WebForms to me is just tedious and sometimes very frustrating. Especially if you need to break out of its abstraction and do anything it wasn't designed to do. Some people may chuckle a bit about factoring in whether developers will enjoy something or not into a technology decision, but I think it makes a lot of sense. If you have two technologies that perform relatively the same function, and developers enjoy working with one and not working with the other then it is pretty clear to see that all things equal, developers will be more productive in the technology that they enjoy.
Gravatar
Chad Moran - Thursday, April 23, 2009 - Great post Rob. I agree I think ASP.NET MVC is a developer's web framework. FOR US BY US!
Gravatar
Shiju Varghese - Thursday, April 23, 2009 - Hi Rob, Nice post. I completely agree with you. I have been involving with ASP.NET since .Net 1.0 beta version and now I am love with ASP.NET MVC.
Gravatar
Haacked - Thursday, April 23, 2009 - Rob, you're a riot! :) I do find it funny when people write spaghetti code in MVC and then say "look! Spaghetti!" Hey, I can write spaghetti code in Web Forms too! I can write it in rails, PHP, Java, Javascript, but not Lisp. But only because I can't yet write anything in Lisp. And when I do write spaghetti code I don't look at my plate glumly expecting to see macaroni. The point people often make when comparing it to classic ASP is that with classic ASP people tended to mix concerns. Pages would have view logic with user input handling mixed in with model code and business logic all mixed up in one. That's what the spaghetti was about! Mixing concerns all in one big mess. With ASP.NET MVC, if you follow the pattern, you're less likely to do it. Yeah, you still might have a bit of code in your view, but hopefully that's all view code. The pattern encourages you to not put your user interaction code in there. Put it in the controller. Put your model code in a model class. There. No spaghetti. It's O-Toro Sushi now. :)
Gravatar
Chris Brandsma - Thursday, April 23, 2009 - I'm right there with you on this one. It probably wasn't until I became a full-on JQuery geek to realize it though. That is when the seems in WebForms started to fall apart. I still haven't managed to jump ship, but I'm heading that way and not looking back
Gravatar
Maarten Balliauw - Thursday, April 23, 2009 - Totally agree with this post, especially: "ASP.NET MVC makes you think". Whenever we have someone new developing in ASP.NET MVC for the first time, they are doing complicated things at a certain moment. I always tend to say: "rethink that!". In most situations, the complicated piece of code a developer is writing can be made a lot easier and nicer by just thinking from a KISS perspective. Keep up the good work with ASP.NET MVC guys!
Gravatar
minhajuddin - Thursday, April 23, 2009 - Awesome post, And to any beginners who are new to web development, I would ask them to learn just ASP.NET MVC, because Webforms pollutes your brain.
Gravatar
dan - Thursday, April 23, 2009 - hi rob i've been reading your blog for a few months now. just wanted to say this is one of my favorite blogs because the posts are not only informative but crack me up! keep up the great work as for asp.net MVC, i've been using it for about a month and i am definitely having fun with the experience. one thing i really like about it is that it seems to push me towards better coding practices so my code ends up structured in a pretty clean and logical way (ie. models handling the business objects, views for displays, controllers for user interaction)
Gravatar
Sabanito - Thursday, April 23, 2009 - Rob, great post. This is the first comment I put in your blog, but I've been following your work since I first read about Storefront. In fact, my company is building it's new version of a big system in MVC because of your work in the Storefront (as an inspiration), and the wonderful things (and fun) you can do with it.We're loving jQuery. I just have one dream... that someday in the future we'll see some powerful controls like in the webform world (specially for the grids, like DevExpress and others)
Gravatar
josh - Thursday, April 23, 2009 - huzzah! Thank you, and going to post a link on my blog so all 2 of my readers read this too. (be nice to my mom and dad when they click thru) I tried to make a pro-mvc argument on my blog, but I dont think I put it as well as you.
Gravatar
Lorenzo Bolognini - Thursday, April 23, 2009 - Thanks for posting this, and no, it's not because MVC is fun: it's because it's the only framework MS shipped since Classic ASP that gives you total control over the output, which should be what you want and what you need to do web development right.
Gravatar
Przemek - Thursday, April 23, 2009 - My colleague developer has been doing some reading about the new MVC Framework. We have had a short discussion about the new possibilities that it brings to the table and he asks: "But how do you drag a grid to the design surface?" Gee... The widget mentality has been spoiling us... it might be hard to combat it. But, let's give it a try.
Gravatar
Leonid Shirmanov - Thursday, April 23, 2009 - I quess all we are in a way to javascript ajax controls so perhaps in a near future there will be no need in Spaghetti code. Views are just a layouts, js controls are calling controller actions getting json back. Javascript controls are going to be generated from C# code using Script# or something similar.
Gravatar
Robin Massart - Thursday, April 23, 2009 - Interesting post. I think it's time for me to start switching to MVC - and not just playing around with it a little. I only switched to Webforms about 3 years ago (straight into .Net 2.0) and coming from Classic ASP I think your point 4 is spot on: "It Makes You Think… This is the one thing I never liked about WebForms – I never felt like I was thinking – just solving." I always felt in Webforms I was trying to understand how to do things the Webforms way. I never really felt like I was desiging a solution the way I wanted it to be. Webforms were great for getting things done in a certain way. But modifying Controls just seemed to end up in a solution more complex than the equivalent in Classic ASP. I should also state that your blog is one of the main reasons I stuck with .Net and C#, rather than switching to something like RoR or Django. I'd grasp the theories behind things like TDD and MVC but theory is one thing. Practice is another. For someone who has no other IT literate colleagues to learn from or bounce ideas off, your posts on MVC, TDD and the storefront app have been invaluable and kept me interested in hanging around for ASP.Net MVC. Thank you!
Gravatar
BorisCallens - Thursday, April 23, 2009 - Rob, can I give you a hug? Finally an inside man yelling what others have been writing between the lines. I like yelling people. To further bolster your case you might want to consider these: - Nr1 reason CSS fails cross browser is invalid HTML. Browsers try to take their best guess at invalid HTML and best guesses usually aren't good enough. - Say NO to automatically generated inline CSS - Say NO to automatically generated inline JS - The ID tag isn't murdered anymore, so you can actually use the DOM. - classic asp.net is geared towards IE rather then standards (read: all other browsers) - you get to choose if you want to rely on JS for postbacks or not - classic asp.net made accessability a joke (or the attempts to comply to it at least) - REST got raped without ever giving something in return (it should have been a big gift to forget about the raping) You can read these and other arguments on my SO comment made some time ago: http://stackoverflow.com/questions/46031/why-does...
Gravatar
stephan - Thursday, April 23, 2009 - My cat can and does sing like Susan Boyle, thank you very much!!!
Gravatar
Chuck - Thursday, April 23, 2009 - For some of us, MVC represents the swing of the Technology Pendulum. ASP.NET was a reaction against ASP and provided an apparently stateful way to write web applications. In short, it made Web development easy and accessible to many levels of developers. However, the ASP.NET model in general encourages bad programming principals because it encourages such tight coupling between layers. I am ok with writing more Javascript/HTML simply because the toolset is much, much better than Visual Interdev Good Post Rob
Gravatar
Ruairi - Thursday, April 23, 2009 - Agree with everything that's been said. But the fact is most people commenting are always ahead of the curve with technology change. The really people that need to be targeted are the "paint by numbers", "drag and drap" ASP.Net "developers". If ASP.Net MVC is to go mainstream then Micorsoft and the Visual Studio tools need to make the MVC/JQuery approach easier for the not so skilled developers. The MVC framework is great, but the gain traction their needs to be a standardized "plugin" strategy (like sub-controllers or MEF). Then the Visual Studio team need to biuld the GUI to allow novice MVC developers to drag and drop their "MVC/JQuery" controls into their project. The use of T4 and the dialog boxes for Adding New Controolers and new Views, is an example of where MS need to go to improve the ease of use of ASP.Net MVC. Novice developers need this to ease them into MVC. MS need to take it further and make it more "drag and drop" so you can drop pre-fabricated controllers/models/views. And give a open API so we (the community) can be creative. I'm not suggestion we go back to ViewState and traditional controls, just make it easier for novice developers, who have a very sleep knowledge curve to climb!
Gravatar
EvanHutnick - Thursday, April 23, 2009 - Alright, you've just officially convinced me to hit up some MVC tutorials today and start giving it a try. My first experience was somewhat slapdash, as I fit it in between my main Webforms development and a new Silverlight project, but now the semester is ending (cheers for no more full time school and work!) I think MVC may be the next mountain I climb. And I also fully support everyone learning Javascript with the help of jQuery, it really does bring the "wow" effect back to working on websites.
Gravatar
Steve Willcock - Thursday, April 23, 2009 - 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 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 Ruby on 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 Microsoft's officially sanctioned version.
Gravatar
Jim - Thursday, April 23, 2009 - My first experience with web development was PHP. I spent many hours learning how to craft HTML. But current my job introduced me to ASP.NET webforms. I know webforms tries to make everything easier, but I found I spent too much time learning webforms and not web development. To me, everything makes more sense in ASP.NET MVC. I will never go back to web forms.
Gravatar
darkYuris - Thursday, April 23, 2009 - "Today I read a post on StackOverflow which was pretty contentious wherein the author says" hahaha... i read this one too. ^^
Gravatar
Bill Pierce - Thursday, April 23, 2009 - +1
Gravatar
Esico - Thursday, April 23, 2009 - .. you had to learn those things too if you went for rmvc
Gravatar
Rick Dailey - Thursday, April 23, 2009 - @BorisCallens: Absolutely, I forgot to mention Accessibility. This is huge. I don't know how many times I've had to explain to other developers why not to use AutoPostBack on their dropdownlists. Or why LinkButton using JavaScript can be a problem. Or why <form> should not surround your whole page. Or to use <label>. The simple fact is, not all humans use the internet (or their computers) the same. Some use text-to-speech because they have no vision or low vision abilities. Some people don't use the same input devices as others, or don't have the same kinds of motor abilities. And that doesn't mean they don't "deserve" access to your content or functionality. If you're using WebForms' default rendering, might I suggest trying to use your site with a screen reader?
Gravatar
Nick Berardi - Thursday, April 23, 2009 - Hi Rob, I am the author of that post and the upcoming book: http://www.amazon.com/dp/0470410957?tag=omniporta... That post was an early working copy of Chapter 2, the table has since been redesigned and refined to be more Jeff Foxworthy/"your might be a red neck if..." type of table. So now the table consists of about 6 questions of "You might want to use MVC if..." sort of statements. I will be doing an update on the post pretty soon to address this table. Nick
Gravatar
Trevor - Thursday, April 23, 2009 - I love this line - "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. " For me, learning ASP.Net MVC has been the most fun I've had programming in a long time.
Gravatar
Travis - Thursday, April 23, 2009 - You're a jerk. (Just kidding, great post)
Gravatar
Pop - Friday, April 24, 2009 - Asp.net MVC is so awesome and it follows lots of design patterns. You cant go wrong with MVC.
Gravatar
balaji - Friday, April 24, 2009 - Rob, thanks to you i have been using Mvc from ctp 4.0 and completed two projects with it.You are great and really coding in mvc is really intresting.
Gravatar
Carl - Friday, April 24, 2009 - I think this is a great post Rob, thanks. It did strike me as strange, however, that there it was not accompanied by a link to the free download of Chapter 1 of your book. When I finished reading your post, it prompted me to fire up that chapter and have a go and I am suitably impressed. I love the idea of walking through the creation of a functional MVC site as the opening chapter in the book, and because it was authored by ScottGu, it's very easy to follow and thorough. http://tinyurl.com/aspnetmvc (hope I'm allowed to post hyperlinks in here... If this chapter is anything to go by then I can't wait for Amazon to get themselves into gear and send me my pre-ordered copy!
Gravatar
Pop Catalin - Friday, April 24, 2009 - I'm not a primary web developer but I used to do web development in PHP, some classic ASP and some JSP about 4 years ago. I never was comfortable with ASP.Net programming model (the webforms part), it doesn't seem natural, it doesn't follow the way the web works. I'm sure glad ASP MVC is out and that Microsoft invested time and resources in it. It's programing model is the model that I find comfortable to work with, where everything is in my control (markup, scrips, etc). I always felt that ASP.Net webforms is a model that wasn't made to serve web developers, but developers that don't know how the web works, which is a bad thing unless you're building a intranet corporate website, where all that matters is how fast you build it, without caring about optimizations or standards compliance.
Gravatar
Jay Gee - Friday, April 24, 2009 - You remind me of the brokers who sold to an unsuspecting public those exotic financial products without mentioning any down side. One argument people give for MVC is performance and scalability. In big apps there are many villains but it usually isn't the request/response lifecycle. Instead there are memory leaks, bad stored procedures and/or a middle tier that moves data around unnecessarily. MVC doesn't solve this problem. Software professionals do. MVC in the context of ASP.NET and the so-called MVC roadmap are in their infancy. Commit your client's money to an MVC project now that takes more than a few weeks to build and you commit your client to an app that is DOA. That's because the MVC framework is evolving quite rapidly now, And if we wait long enough the choice between MVC and Web Forms will prove to be a false dichotomy. I know this roadmap will dishearten the true believers -- the aesthetes. However, aesthetes shouldn't hook their star to Microsoft. Microsoft is about Christmas trees. Microsoft is Word. Microsoft is bling. Long live Microsoft. Long live bling.
Gravatar
Sean - Friday, April 24, 2009 - Long time web application developer here (PHP), and new to ASP.Net. I do plenty of .Net WinForms coding at work though. What are the implications for using MVC in combination with some of the 3rd party web controls out there? Are they compatible at all? I am guessing probably not. For example, our company purchased the ComponentOne suite. We are planning a Web based version of our product. If we go with MVC, is it possible to use the Web controls? Or is this more akin to coding web apps in PHP, for example, where you basically hand code *everything*?
Gravatar
Manuel - Friday, April 24, 2009 - I believe this is a useless discussion, there is only one scenario where ASP.NET MVC beats web forms: Complex web applications. Why, because web forms is BAD for that type of applications, my colleagues at the project next door can explain you why, using web forms on their application has caused Saturdays and Sundays lost, an infuriated client, and a huge economical loss for the company. So if you are building web apps for dummyes don't even bother with MVC, but if you are building something complex the organization and separation of concerts that MVC brings to the table is a must.
Gravatar
HopefullyMVC - Friday, April 24, 2009 - All well and good, except you just kind of come across as sarcastic and condescending. The arguments agains webforms are strong in terms of the output HTML and the use of jQuery etc. But you can't just hand wave away concerns webform users have about the speed of development. And whilst some of you might snigger at drag and drop, i'm also pretty damned sure that you won't be sniggering so much after you've recreated the same gridview/update panel etc etc code for Nth time by hand. Drag and drop is there for a reason its quick (and yes dirty) but if it gets the job done as it does in many cases. I think you'll find it hard to explain to a client why you'll have to do it the MVC way and take more time over it rather than doing a drag and drop. Most of us work to deadlines, more often than not unrealistic ones not of our own choosing. Whilst i'm keen about MVC until you put these concerns to rest i don't see how you're going to win diehard webformers over.
Gravatar
kevinw - Friday, April 24, 2009 - Maybe I don't "get it", but what is the difference between seprating out all of your business logic into a separate DLL with web forms, and the separation of MVC?
Gravatar
HopefullyMVC - Friday, April 24, 2009 - Oh and by the way, the comment about Webforms being an abstraction...But frameworks are abstractions. That's the whole point, to hide the ugliness (i suppose you'd say that webforms brings more ugliness *because of* the abstraction, and i'd agree, but it greatly increases development time). I'm sure you'd never complain that NHibernate abstracts away the need to directly delve into SQL queries, so why the angst with Webforms abstracting away statelessness of the web?
Gravatar
Andrew - Friday, April 24, 2009 - @HopefullMVC "But you can't just hand wave away concerns webform users have about the speed of development. And whilst some of you might snigger at drag and drop, i'm also pretty damned sure that you won't be sniggering so much after you've recreated the same gridview/update panel etc etc code for Nth time by hand." Why would using MVC prevent code reuse? Sure, it's different than Web Forms development, but the DRY principle is the DRY principal.
Gravatar
Magnus - Friday, April 24, 2009 - Good post! I think separation of concerns should be on that list as well. It's not that long ago when the concept of separation of concerns was never discussed in the .Net community. I'm glad things are finally changing for the better and I agree that ASP.NET MVC is a big step in the right direction.

I'm interested in your book but I was a little disappointed when I saw the NerdDinner code at CodePlex that have been released. Your samples in the Storefront and Kona have much more complexity and teaches great concepts like DI and best of breeds frameworks while NerdDinner seems more on the simple side. Are you going to have more complex examples in the book or is it geared more towards people with little experience of MVC and those concepts?
Gravatar
Magnus - Saturday, April 25, 2009 - Good post! I think separation of concerns should be on that list as well. It's not that long ago when the concept of separation of concerns was never discussed in the .Net community. I'm glad things are finally changing for the better and I agree that ASP.NET MVC is a big step in the right direction. I'm interested in your book but I had hoped the NerdDinner code at CodePlex were in the same vein as your samples of the Storefront and Kona. I liked the complexity of your samples and that they showed how concepts like DI and DDD can be integrated into the ASP.NET MVC framework. Are you going to have more complex examples in the book or is the scope mainly on the MVC framework and unit testing?
Gravatar
Stealth - Saturday, April 25, 2009 - We've been busily implementing a large project using ASP.NET MVC and I must say, I do like it. I think MVC will be a great addition to our toolbag. That said, I still think the Web kind of sucks. I'm certainly amazed at the superhuman efforts that have made the web a tolerable place to be, but really, it sucks, at least from a coding standpoint. CSS was an awesome idea, but ultimately fell flat on its face as no-one could interpret the "standard" the same way and while Fire Fox, Chrome, Safari and IE can all point fingers at one another, the bottom line is, we have a pile of crap to work with now. I know some of you die hard JS, CSS, HTML, ActiveX, Java Applets, AJAX, REST, SOAP, Adobe Flex, Flash, Silverlight lovers are crawling out of your skin right now, but seriously take a step back and think about it. If you were tasked with creating a framework or platform which would deliver on all of the things the web is now asked to deliver, would your really create this pile of rubbish? A band-aided hack upon another hack with more hacks on the hacks...blah, blah, blah, spaceship. I doubt that you as a skilled developer would ever engineer what we have today, but nonetheless, I hear developers defending the web as if it was some divinely inspired platform? Really? Until we can all realize that what we have to work with in the web is fairly underwhelming, we will just get more hacks delivered to us and we will all blow smoke up each other's @#$$ celebrating the goodness that we've been given...wake up already.
Gravatar
felar - Monday, April 27, 2009 - I originally am a web guy. Although I'm officially an .NET developer, I like messing with design, HTML, CSS, JavaScript and I like it clean. During the last two years of experience with ASP.NET and coming from hand made PHP world, I was honestly horrified with Microsoft web technology. How can someone work with something like that? Doesn't anyone understand that web is nothing like Windows forms, I kept asking myself?! But, because of the certain circumstances I carried out developing using ASP.NET regardless of it's crappiness. We had substitutes for most of technologies which Microsoft offered as the official so called "Microsoft way". Data access - NHibernate, version control - SVN, builds - ant, logging - log4net, unit testing - NUnit and numerous custom made solutions for content management, localization, data tables, forms, web navigation, etc. Why the hell were we using Microsoft technology anyway...? And just when I was just about to give it up and swich back to PHP or Java, Microsoft finally pops ASP.NET MVC, admits that DataSets aren't in any way a good enterprise solution for data access and delivers the technology they had to deliver a looong time ago. MVC has been around for ages (as well as O/R mapping btw). There is absolutely no doubt that this technology is superior to what has been previously "invented" by Microsoft - the stateless web-event driven paradigm-something to flatter the ex-Windows Forms guys. ASP.NET now finally is the true web technology! I am very happy this now became natively supported and I hope it becomes a standard way of developing ASP.NET applications.
Gravatar
Secret Admirer - Monday, April 27, 2009 - Stealth, You're wrong! The web is great to develop against. I'll tell you what sucks... Oracle and EF! If you want to rant about something, then rant about using Oracle with Entity Framework! Wow! Whatever idiot at my company decided to use that winning pair should be dragged out the back and shot to pieces. I've got one more question... Why do the Linq examples only work with Sql Server and Northwind? Seems like a minor oversight for the rest of us.
Gravatar
infocyde - Tuesday, April 28, 2009 - Sigh...I really wish all you blogger folks wouldn't phrase things like this. "You really should learn this new fad, else you aren't down and should get out of programming." Which is essentially what you did, and yes you are a jerk, even if you might be correct :) On one level I get what your saying. I had to work on some classic asp projects recently and I actually did start to enjoy working on them a lot more then I thought because I was closer to the "roots of the web". I had total control, I through in some jQuery and Ajax, and those classic asp apps started to work like any Web 2.0 app should. I do look forward to working the ASP.Net's implimentation of the MVC pattern here soon for that reason, but please, save the fad programming pattern of saying "Your in the wrong business if you don't follow/learn the latest framework/pattern/methodology/test suite". Especially as your post is hosted on "ucky" WordPress PHP code :)
Gravatar
webdevtn - Wednesday, April 29, 2009 - OMG!!! There is someone that actually thinks the same way I do. " 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? " Having to do this just makes my skin crawl. "We’re only now catching up with frameworks that have been creating rocking, compelling sites over the last few years " Being primarily an MS developer, I started doing cartwheels (and a bit of moaning cuz it was ruby and not c#) when Rails came on the scene. When the ASP.Net MVC came out, my only comment was "bout time". The LAMP community has understood the power of this methodology for a while now and I feel like we're just now catching up. Keep of the awesome work Rob, your a great inspiration.
Gravatar
John Repko - Saturday, May 02, 2009 - Excellent! This is what you so totally missed back when you wrote "Imploding Rails, Jesus DHH, and The Uncle Ben Principle." Rails aficionados' love of Rails has always had NOTHING to do with DHH or opinions of the core team. The love comes from what I wrote in the comments: "Lack of Natural Antipatterns." WebForms takes an antipattern (cluelessness about how the http protocol works) and bakes it into the entire development framework. So yes, while WebForms development efforts can somehow be MADE to work -- that is their curse. If the framework had been only a little worse, it would have been rejected outright. Now, we're stuck with a lot of dreadful legacy efforts. Oh well -- progress is still progress.
Gravatar
vkelman - Wednesday, May 06, 2009 - Rob, Thank you for this post! There is one more major flaw in WebForms. What is always surprising me, that people are not crying continuously about it. It's a consequence of a rigid pre-defined structure: there is no reasonable way to make Back button work. There is no way to follow correct Http logic when you use GET operation to generate a View and use POST operation to modify data. To me, POSTBACKs are the biggest evil in WebForms. Even in "messy" classic ASP (which was not so messy with extensive use of include files) I always followed Post/Redirect/Get (PRG) pattern. There is no feasible way of doing it with WebForms, so that dreadful "Webpage has expired" pop-ups after hitting Back button are unavoidable (don't mention UpdatePanel, please!). http://www.strong-point.com/Blogs/tabid/87/EntryI... http://www.strong-point.com/Blogs/tabid/87/EntryI... ASP.NET MVC finally allows to use clean Http and HTML - that's simply great!
Gravatar
Neil - Wednesday, May 06, 2009 - Thanks Rob. Glad I'm not the only one out there who finds WebForms an abomination that creates a ugly abstraction layer between the developer and the code. There is a reason I don't write my websites in FrontPage and a reason clean sites require you to know (and care about) your HTML, CSS, JavaScript, and the DOM. I look forward to learning MVC and seeing if it's the framework I'm been waiting for! As for the "ease of use" argument, I have always found that it is faster and easier to hand-code complex components than to rely on drag-and-drop solutions that take forever to deconstruct and tweak to do what you really want/need them to do. Sure these tools may speed up some tasks in some situations, but those of you that have learned your webapp development using nothing but these kinds of crutches need to dig deeper into the code. There is a world of different between tools like jQuery that help you more efficiently implement code and tools like WebForms that try to hide what's really going on under the hood. Oh, and Rob? You just sold another book. :)
Gravatar
Mario - Tuesday, May 19, 2009 - Refreshing post! Nice to see an inside man speaking his mind ;)
Gravatar
Trevor - Friday, May 22, 2009 - 1) The instinctive "I can write spaghetti code in any language" retort to someone complaining that MVC code looks like spaghetti is clever, but to that I would say "Ok, fine, but can you write code in MVC that *doesn't* look like spaghetti, as I can do in webforms?" (Not trying to be a wise guy, its a serious question I have). Everything I've seen in articles I've read looks like frickin classic ASP! 2) The idea of raw writing out the html for a table, for example, turns me off (as opposed to using a nice dataview control); but, is it possible to just call a helper function (self-authored i guess) passing (a dataset?) to it, that will just build you a default table? 3) The loose coupling bothers me, ie: FirstName vs FristName I like the compile time checking in webforms, is this totally lost in MVC (which I guess is offset somewhat by the improved testability)?
Gravatar
vkelman - Friday, May 22, 2009 - @Trevor, I don't know strict definition of the term "spaghetti code", but to me a good classic ASP code is much easier to understand and follow than WebForms code. Just replace poor VBScript to C#, allow conditional includes, and IntelliSense - and you have almost perfect flexible environment (too flexible, I admit). On the other side, WebForms code is only good when one refrain from using complex (overcomplicated) server-side controls like ListView. My team, enthusiastic after switching from an obsolete classic ASP to a modern and powerful ASP.NET 3.5, and after thorough reading of classic "ASP.NET Unleashed", decided to follow all those examples showing super-powerful ListView control. No one was listening my arguments, that combining read-only list view and edit/add-new views on the same page is wrong, regardless of technology used. Guess what we got? Unmanageable mess, 2-thousand-line code-behind page, doing all those non-related things. Despite the fact we're using clean N-Tier design, there was no way to write decoupled cohesive pieces of code. And those unbearable "Webpage has expired" pop-ups after hitting Back button... so we added several Update Panels... and code became a nightmare. Even with classic ASP you could follow good design practices if you wanted, ASP.NET MVC prompts you to do so, but WebForms simply prevents you from doing so - unless you refrain from using design-time controls, which makes WebForms useless.
Gravatar
vkelman - Friday, May 22, 2009 - BTW, look at so called "Futures" library for MVC. It provides with strong-type HTMLHelpers, so that you don't use string names for controls on a view and there is no chance to misspell and compile. To me, there was one useful design-time control: a GridView. But I'm sure there are plenty of replacement for it in ASP.NET MVC world. Starting from grids in jQuery UI. Another thing I liked to use in classic ASP.NET was Menu control. Here's one good source of information (besides this blog author's pages): http://blog.maartenballiauw.be/category/MVC.aspx
Gravatar
Trevor - Monday, May 25, 2009 - @vkelman Thanks for the tips. (Sorry when I said dataview, I meant gridview) I agree that webforms taken too far can be a disaster. I agree with much of what you've said. Just what I've seen so far of MVC looks messy to me...I hate seeing logic embedded within html....I can handle a little looping....I hate having to hand code a <table>. I will check out the two things you posted, they look promising, may solve some of the complaints I have! :)
Gravatar
gerry lowry - Tuesday, June 02, 2009 - I'm thrilled to read this. Yes, thrilled. People with the courage to choose a side of the fence to be on are rare. People who actually have a good reason for that choice are even rarer. To add ASP.NET MVC to my repertoire, I've had to accept that like c++, c# actually is a language (thank you Tom Archer for "Inside c#"). I've had to learn about xUnit.net (thank you Brad Wilson and James Newkirk). I'm also trying to master Moq (thank you Daniel Cazzulino), CSS, Ajax, ... Alas, if only I had a cat that could sing like Susan Boyle and a wig for it ...
Gravatar
TRU|believer - Wednesday, July 01, 2009 - i'm glad i read this before building my first blog out of ASP.NET. i was going to let blogengine.NET do the work, but nah i'll be an asthete. seems like the MVC way will be more interoperable with the way the web is shifting.
Gravatar
gerry lowry - Saturday, August 01, 2009 - There are four nerd diner nerds, We've hear from one that's ornery, but what about the second, third, and the head honcho fourth? Speak up! Speak up! Scott, Phil, and Scott! You've all got opinions for the rest of us minions Scott, Phil, and Scott, give us a thrill, like ornery Conery, speak your will, please don't be afraid, 'cause Uncle Bill never reads Rob's blog, (lucky for Rob). Scott, Phil, and Scott, please be so kind, share with us what's on your mind! P.S.: since writing this article, it is rumoured that Rob Conery has not been seen. I know that's only a rumour because I just started it. B-) Regards, Gerry (Lowry)
Gravatar
Santos Victorero - Sunday, August 02, 2009 - Are you still working there? :-) Maybe some of "they" think you are having "delusions of grandeur" but they need more big mouth like you there! Some people say that "If you are not having fun you are not doing it right". MVC is great and I am having a lot of fun building stuff with it. Keep up with the good work! I used to have a big mouth too but you know how to write. ;-) Santos
Gravatar
CitizenBane - Thursday, September 03, 2009 - I'm glad I'm not the only one who thought, after switching to ASP.NET MVC from WebForms (originally from classic asp), "Wow, Programming is FUN again!"
Gravatar
Lester - Tuesday, November 03, 2009 - Microsoft.MVC sucks!