Fight the Rewrite
Fight the Rewrite
Image Source: XKCD
An old boss invited me to lunch yesterday. As we were sitting there waiting for our food we were reminiscing over the early days of his company. He made a statement that made me want to cringe:
Ahhh, JP… I remember when you were looking at the code that Dan [the first dev at the company] wrote. You said: “This code is crap, it needs to be rewritten!”
I unfortunately didn’t have the gumption to tell him that I made a mistake claiming that the code needed a rewrite. It’s true that I thought the code was messy. But, in my anecdotal experience, it seems to me that most developers that look at the code written by other developers, think that the code is crap. Actually, developers that look at their own code years later think that their own code is crap. They are probably right; the code is crap.
But, to believe that a rewrite is needed, is a junior mistake.
There were business assumptions made that you can’t possibly know now. Plenty of undocumented business assumptions that the code will handle just fine. You can’t possibly account for all of them.
I like what Joel Spolsky writes on this, Things You Should Never Do:
We’re programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We’re not excited by incremental renovation: tinkering, improving, planting flower beds.
There’s a subtle reason that programmers always want to throw away the code and start over. The reason is that they think the old code is a mess. And here is the interesting observation: they are probably wrong. The reason that they think the old code is a mess is because of a cardinal, fundamental law of programming:
It’s harder to read code than to write it.
This is why code reuse is so hard. This is why everybody on your team has a different function they like to use for splitting strings into arrays of strings. They write their own function because it’s easier and more fun than figuring out how the old function works.
As a corollary of this axiom, you can ask almost any programmer today about the code they are working on. “It’s a big hairy mess,” they will tell you. “I’d like nothing better than to throw it out and start over.”
When you hire a developer, and he wants to rewrite code that seems to be working just fine, fight it. He may claim that Java is old and slow and that Ruby on Rails is cool. Maybe he’ll throw a bunch of buzzwords at you. Either way, really consider it.
What do you think?
You might also enjoy:
- Customers Demand Native for Mobile Apps
- Software as a Vision
- It’s All About the MVP, Obey Gall’s Law
You should follow me on Twitter: @jprichardson
If you made it this far, you should follow me on Twitter. Follow @jprichardson