Tim on Leadership

Musings on Management and Leadership from Tim Parker

Code Review Tango

All too common a statement: "I don't need a code review!  I don't write bad code!"  You may be surprised to know how many times I hear that from developers, from junior to senior.

The simple fact is most of us have particular coding styles, tricks, and techniques we have developed over the years.  Sometimes we start off writing "standard"  code (the sort of stuff you see in textbooks and that is encouraged in coding standards), but almost all of us end up modifying our cod to meet our own development approaches.  It's not unusual for someone to write some stub code, intending to go back and flesh it out, only to forget and leave the stub alone.  Or, when coding top-down, to "intend" to write the error trapping stuff but never getting around to it in the rush to get code out the door.

It's not that we're bad coders.  Usually the code is good, sometimes very good, and rarely, excellent.  It's just that time is always the push, not code quality.  That's why we end up letting silly mistakes go out, even if there's no error or warning from the compilers.  We don't intend to make those mistakes, they just happen.

Code review is intended to have a fresh set of eyes look at your code, looking for those things we forget to finish.  Code review is NOT about judging whether code is good or bad, although we all form subjective opinions when we read other people's code.  What code review is about is checked adherence to standards and finding the "oops!" mistakes we all miss (seeing the forest for the trees syndrome).

Personally, when I was first told my code had to undergo code review while working at Wang (around 26 years of age), I was insulted.  I thought it was about them not trusting my code.  Then, the reviewer found an "oops!" mistake I made, as we all do, and also had some useful ways to tweak the code he showed me, and I realized it was more about peer review than management review.  I also enjoyed reading other people's code, seeing how they wrote programs and, while I didn't like them all, I did see a few things I adopted in my own coding.

So, when we talk about code review, don't take it as an insult.  It's part of a process to help ensure code quality is high, as well as to follow proper software development methodology.  And that is a subject for another day.