Before the first concrete information about 2.0 came out, promises about massive code reduction were being made. “I can’t say too much at this point…one of our aggressive goals is to reduce the number of lines of code between v1 and v2 by 70%”. Every book, article and blog quoted that oft-repeated line from the ASP.NET development team. Even when 2.0 was still a year away, we were told that goal was almost reached. Glory hallelujah!. Fast forward to today, months after the 2.0 RTM and you’ll quickly realize there is no silver bullet (heck if OO couldn’t do it for us, we were fools to ever believe ASP.NET would).
Every developer thinks his or her code is going to save users and clients 70% of their time. Every time I build a new application I envision mass-workload reductions and international “Karl Seguin” holidays. It’s some type of global developer hubris (in the modern sense, not the Greek one), and Microsoft developers are far from immune. But aside from the forgivable enthusiasm, why aren’t I (and I assume most people) writing 70% less code?
First, I consider myself an ASP.NET developer, but I probably spend less than 25% of my time in aspx and codebehind files. Most of my time is spent in my domain, data access and data layers. Much time is sent writing modules, handlers and server controls. Even if I managed a 70% code reduction, it’d only put a small dent in my overall coding.
That point aside, I do think some of the time saving features were just blown out of proportion. One of my favorite example is everything revolving around the new Membership provider. Yes it’s great and yes I use it. But I needed it’s functionality over 3 years ago, so I built my own. I was already saving code by using composite controls for my login, registration and password retrieval along with a flexible business and data model. The 2.0 stuff is better than mine, but it doesn’t save me from writing any code I didn’t already have.
Secondly, much of the reduced code comes with strings attached. Take the built-in paging and sorting of the datagrid or the gridview. You’ll end up paying a huge performance hit for any medium-to-large data set (not necessarily DataSet). Anyone who’s had to page results with any type of performance implication _always_ does this at the data layer. Then there’s the SqlDataSource, which I love picking on. Sure you can write this application with few lines of code, just forget everything you ever learnt about programming.
Thirdly, declarative code is still CODE. Not to be rude, but it’s bullshit that 5 lines of code to declare my ObjectDataSource in my aspx should be considered as less code than the 2 lines it took to bind to my [highly reusable] business layer. Yes, a designer generated it (btw, clicking next 3-4 times still takes longer to do than to write those 2 very short lines), but a human will have to maintain it.
You want to know what really makes me productive? Spending time upfront to properly architecture my application. Making use of libraries, such as Log4Net and Patterns and Practices code block (along with my own, for example localization). Generics are the real 2.0 feature that save me a ton of code (nullable types are a let-down). Tools like SourceGear’s vault, JetBrain’s Resharper, DevExpress’ CodeRush and CodeSmith Tools’s CodeSmith are key. Not to mention everything made by Red-Gate.
It seems that the only sites that benefit from any code reductions are either the ones being developed by bad programmers or the ones that had little code to begin with. Sure, I’ll drag and drop a couple controls for my dad’s webpage, and it’ll save me 30 minutes – great. But for the sites I spend months working on, saving 30 minutes upfront is going to violently bite me in the ass.
The ASP.NET team is passionate and excited about what they do. That’s really all I’m accusing them of. I don’t feel lied to whatsoever. I am somewhat skeptical of the MS Marketing machine (95% caused by longhorn, 5% from continuously losing anti-trust lawsuits), but I don’t think that’s intentionally what happened here.
I do have two fears. First it’s that the ASP.NET team may be disconnected with .NET developers in some respect (a topic I want to explore in greater depth another day). More of a concern is that little material is created from the ASP.NET team about sound design and architecture. Every time a demo, tutorial or whatever includes an SqlDataSource, an angel looses its wings.
By way of closing, it must be stated that I hate posts with negative undertones that start off with an apology – they always seem so fan-boyish. The phrase “don’t get me wrong, I love XXX; but…” makes my ears bleed. Obviously I feel my complaint is legitimate (I hope if you disagree you’ll let me know), but I don’t think it’s a huge issue, more like food for thought.