"It's harder to read code than to write it."- Things You Should Never Do, Part I by Joel Spolsky in Joel on Software on Thursday, April 06, 2000
Here's the wider context, just a snippet from Joel Spolsky's wonderful post:
Netscape 6.0 is finally going into its first public beta. There never was a version 5.0. The last major release, version 4.0, was released almost three years ago. Three years is an awfully long time in the Internet world. During this time, Netscape sat by, helplessly, as their market share plummeted.
It's a bit smarmy of me to criticize them for waiting so long between releases. They didn't do it on purpose, now, did they?
Well, yes. They did. They did it by making the single worst strategic mistake that any software company can make:
They decided to rewrite the code from scratch.
. . .
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.
Joel was right when he wrote that 11 years ago. If he'd been alive in 1960 he would have been right then.
...and he's right today.
And now for the Fair, Balanced and Incorrect point of view...
Joel Spolsky's business partner Jeff Attwood has written many wonderful articles over the years, but his response is a real clunker:
"I think the way most developers "understand" code is to rewrite it."- When Understanding means Rewriting by Jeff Atwood in Coding Horror on Sep 18, 2006
Wouldn't it be better if programmers tried a bit harder to write code that was understandable when read by others?
Code that could, say, pass something as simple as the Telephone Test?
Go ahead, try that with anything that's even remotely object oriented :)
Next week: Jakob Nielsen