Webforms vs. MVC, the desire to rewrite everything, an unexpected benefit
I read a good post today about the silly wars that go on in versus debates, in this case the arguments about whether to use Webforms or MVC for ASP.NET.
I kind of saw this storm coming when people started describing
themselves as part of the alternative "movement" in the ASP.NET
community.
The truth is that MVC gets me really excited, for a
thousand different reasons. My win comes from the fact that I feel like
I'm no longer fighting the statelessness of the Web by conforming to a
framework that simulates statefullness. Maybe I never really realized I
was doing that. But the nice thing about MVC is that it has forced me
to break down what I'm doing into simple actions. There are two
benefits developing that I had not previously considered.
The
first is that the stripped down nature of the MVC pattern causes you to
back off if you're someone who does UI development. It can be argued
that many of the apps out there now that get all of the press and
attention are ridiculously simple and easy to use because they don't
try to do a lot, and, by no coincidence, happen to be developed on
another MVC framework, Rails. Whether it be Twitter or my wife's
favorite site, Ravelry, there is a simple style that seems
representative of sites developed using this design pattern.
The
second benefit is that adhering to a strict seperation of concerns,
whether it be for reasons of testability or the desire to decouple your
pieces parts as much as possible (or because "they" said so), makes
your code infinitely easier to maintain.
That said, when bouncing
back to a Webforms project, I'm amazed at just how much cleaner
everything I write is in terms of keeping the moving parts minimally
coupled to each other. It's not that I had 10,000-line code-behind
files before, but my mindset has changed enough since spending time in
MVC that I'm a better developer now when using Webforms.
And when
all of the crazy zealots go on and on about how awesome MVC is, I'm not
writing that image gallery control for the hundredth time, because I
did it once years ago. The simple content management apps, handlers and
diagnostic pieces are all there still for me to use, and now I'm wiring
it all together in a much cleaner way.
I love MVC. I mean I really dig it. I can't wait to get some of my projects based on it out into the open (other than my personal blog,
anyway). But the truth is that the value already built into years of
ASP.NET Webforms is not trivialized or bested by the new framework.
Instead, there's a great compliment in place now where I can use which
ever gets me to market the fastest. At the end of the day, rewriting
things for the sake of science doesn't get me paid. Shipping stuff is
what puts food on the table. Now my toolbox is a lot bigger.