Friday, February 11, 2005

Code reviews

Johann Gerell, responding to my 'egg on face' post, asked if we ever did code reviews here.

Alas no.

I've never run a code review but I have been the subject of more than a few in my time. The first was a disaster and I learned much from it. The problem was the one you might expect; the reviewers were somewhat hostile. Yes, that's my assessment of it so you'll have to weigh my personal involvement. Which is exactly the problem! If the reviewers are in any way hostile to the code being reviewed then woe to the poor bugger being reviewed. Equally, if the poor bugger whose code is being reviewed feels it's a hostile environment then nothing will be achieved. One or the other side will dig their heels in and you might as well have not wasted the time.

My second code review was much better. (It was a device driver for a four port serial driver). In part this was because I spent a lot of time orchestrating it. Fortunately I had the ear of a sympathetic boss who understood the issues; he was able to veto one reviewer who was opposed to our platform. If our platform is OS/2 1.3 and there's a reviewer who thinks anything other than Unix S5R4 sucks... (does that tell you how long ago this was? )

They found a dozen or so places where I hadn't checked a pointer I should have, or suchlike.

But much more importantly; I walked away from a day of explaining in explicit detail why I did this and didn't do that. The process revealed a few places where I hadn't checked something important. When we released the driver into production on 7000 machines we had just one bug; which I fixed one day after it was reported. We didn't have a second bug report in the 7 years after that.

So back to Johann's question. Do we ever do code reviews here? No, we don't. Not because I don't want em but because it's impossible to deflect management's attention on the schedule (which changes every day) long enough to take the luxury of actually spending time to ensure that what we're doing is right. We seem to be in permanent crisis. It's hard to maintain the focus when every day has a crisis that 'just has to be solved today'. Indeed, I've stopped trying. When everything is a crisis then nothing is a crisis!

No comments: