On the plane tonight (I'm in Redmond this week) I got to thinking about writing "Maintainable Code" and what it means in light of our fad-centric industry which churns itself every 18 months or so with a new language or platform version. We all inherit projects and are confronted with Geek Lust to rewrite everything in our own image - but what is the motivator for you when you do this?
My question to you is: how often do you justify a rewrite (or upgrade) with a platform rev or language change?
Good Clients
Up until a little over a year ago, I'd had the same client for the close to 9 years: KLA-Tencor. It all started when I wrote a small ASP-classic site for them in 1997 that evolved into a pretty robust Commerce/Fulfillment app in late 2005.
You might think this is crazy, but after the initial rev, I rewrote the site 3 times:
- First Rev: 1997 (basic data-driven brochure site
- Second Rev: 1999. ECommerce application and backend sales-support
- Third Rev: 2002: Upgraded site to .NET 1.1 and added web-service support
- Fourth Rev: 2004: Upgraded site to .NET 2.0 and refactored just about everything.
Four revs in 9 years is just about average for the industry (from what I've seen), and thinking on this really made me wonder if most developers consider platform rev/technology shift (and that of the project their working on) when architecting their site?
I Am A Geek. And So Can You.
We build, we change, we look for better ways, and once found, said better ways are hoisted up on the shoulders of the masses and paraded around the blogosphere.
We're fad-prone (like any industry) and one minute we might be throwing around words like "Paradigm Shift" and "Service Oriented Architecture" and the next we throw in the words "Separation of Concerns" and "Loosely Coupled" to spice up the conversation.
I had a good giggle the other day talking to
Mr. TDD Himself (Steve Harman) on Skype, and the conversation was pretty damn funny. Steve left a comment on my blog about the new stuff we're doing with SubSonic:
Rob, will there be a testing story for the Repositories? That is… how would I go about mocking them out for unit tests so as to avoid hitting the db?
It's a good question. My reply wasn't so professional:
@Steve: if you like TDD so much why don’t you just marry it :p
You have to understand that I love Steve. No, I LERRRV Steve. In fact I love him so much I stole him from right out of Haack's nose and made him a main committer for the new SubSonic MVC stuff (Steve is Phil's right-hand with SubText). Booya!
Anyway - I made sure to follow up the conversation with Steve on Skype to get his ideas, and I asked him what he thought we should do to make some of our new stuff more testable (we have a whole mess of non-virtual, non-interfacable static methods as part of our Data Factory which are not easy to test). He came up with a great plan (paraphrased, geekiness his):
You could crank up an IoC containter and use Dependency Injection...
My reply was my usual not-so-professional-smart-assiness:
Ooooh! I like that idea! And look at all the buzzwords I can blog about!
I hope you don't read this as me being snarky - I couldn't help myself. Steve is such a good guy and he's shown me some great tricks regarding TDD and tools. But see, when you're nice to me, my claws come out and I rip your best shirt while coughing up stuff on your best shoes. I can't help it... it's my nature.
When Do You Tell A Client To Rewrite?
So as I sit there tonight on my plane, watching a Horrible Movie with The Rock dressed up as a cheerleader, I got to thinking about Steve and our conversation (Steve used to be in Glee Club and on his highschool Drill Team).
Unit Testing is something you learn about in school, but let's face it - no one in the MS space took it seriously until NUnit came out a few years back - it's a "wave" that's hitting it's stride right now (and a very good wave it is) and
I'm wondering just how many people will rewrite an old application to be more testable? Even in the case where one might be working just fine?
If you were handed an ASP Classic site (yes, there are many) - let's say ... ohhh...
Starbucks - would you push them to rewrite it? If so, would a complete set of Unit Tests be part of the cost?
A client said to me once (over beers):
It doesn't matter how good the developer tools get, you guys will always find ways to invent work to fill your time and bill me for it.
Interesting point and, from a client's perspective, hard to argue with. I didn't tell him I needed Unit Tests 5 years ago - why are they so critical now?
Again: I'm not criticizing TDD or Unit Testing. Just using it as an example of something that wasn't commonly done just a few years back. Honestly - please don't flame me :). I love Unit Testing. It loves me too. I think. Anyway...
When do you council a client on a rewrite? What sorts of issues come into the conversation in terms of cost/benefit? Have rewrites worked for you and has your client been happy?
I'd really appreciate your feedback on this...