ASP.NET: officially unmaintainable


Recent forays back into “classic” ASP.NET (i.e. not MVC) have me completely convinced that ASP.NET is inherently unmaintainable.  Not partially convinced, not on the fence, but completely convinced that the presentation layer of ASP.NET cannot be maintained in any reasonable manner.

I remember a presentation on MonoRail some time ago, where the presenter asked the audience “how many of you work with ASP.NET in a professional manner?”  A hundred or so hands went into the air.  The presenter then asked, “Now keep your hands in the air if you actually enjoy working with ASP.NET?”  Only a handful of hands stayed in the air.

Now, obviously some peer pressure skewed these results, and it wasn’t a double-blind survey, but it was clear that developing with ASP.NET is a frustrating experience.  My own personal frustrations include:

  • The ridiculous amount of time I spend in Reflector trying to figure out why things that are supposed to “just work” when wired up “just don’t”
  • Not having control over the HTML that is spit out.
  • Trying to do anything with AJAX or DHTML with the insane control names
  • That ASP.NET is the king of leaky abstractions

I try to make the ASP.NET layer as thin as possible, so that the bulk of the application is maintainable.  But even in a MVP setting, the V is still dreadful to maintain.  In the end, HTML is the application, not controls.  HTML is what gets delivered to the client, not crazy post-back event server nonsense.

I knew early on I would have troubles with ASP.NET, back in 2003-4 or so, when I had to use Reflector to get even basic scenarios to work with a DataGrid.  Debugging why control event isn’t getting fired pushes my sanity to the brink.

It also doesn’t help the fact that I’ve never seen an ASP.NET application with unit tests for the code-behinds.  Without tests, your code is unmaintainable.  Since you can’t unit tests code-behinds, you have an immediate charge in your technical debt.  For this reason, I can’t really recommend using plain ASP.NET, almost ever.  Using a real MVC framework in MonoRail was not only a breath of fresh air, it felt like I was the frog getting rescued from the pot of boiling water, never noticing the temperature going up.

So do yourself a favor, take the one week MonoRail challenge.  Try building one aspect or one story in MonoRail, and see how it feels.  Personally, it felt like a crushing weight was finally lifted.  You might feel the same, and with a one-week spike (or even one day), what have you got to lose?

Austin Code Camp 2008 post-mortem