Douglas Crockford
103
Crockford: At each meeting, someone’s responsible for reading their code,
and they’ll walk us through everything, and the rest of us will observe. It’s a
really good chance for the rest of the team to understand how their stuff is
going to have to fit with that stuff.
We get everybody around the table; everybody gets a stack of paper. We
also blow it up on the screen. And we all read through it together. And
we’re all commenting on the code as we go along. People say, “I don’t
understand this comment,” or, “This comment doesn’t seem to describe the
code.” That kind of stuff can be so valuable because as a programmer you
stop reading your own comments and you’re not aware that you’re
misdirecting the reader. Having the people you work with helping to keep
your code clean is a huge service—you find defects that you never would’ve
found on your own.
I think an hour of code reading is worth two weeks of QA. It’s just a really
effective way of removing errors. If you have someone who is strong
reading, then the novices around them are going to learn a lot that they
wouldn’t be learning otherwise, and if you have a novice reading, he’s going
to get a lot of really good advice.
And it shouldn’t be something that we save for the end. Back in the old
days, we would schedule a code reading just as we were finishing a project
and usually it would be canceled because we were late. I now believe that
code reading should be happening all the time throughout the life of the
project. That’s something that took me a while to figure out but there are
so many benefits that come from that.
For one thing it makes it easier to track the project, because we can actually
see what progress people are making. And we can see much sooner if
they’re going off the rails or not.
I’ve managed projects where we’re up against a deadline and we had people
saying, “Yeah, I’m almost done,” and then you get the code, and there’s
nothing there, or it’s crap, or whatever, and they’re nowhere close to done.
In management, those are the experiences you hate the most and I think
code reading is the best way of not getting trapped like that.