...

/

Review Code Early and Often

Review Code Early and Often

Understand the importance of code review in this lesson.

Many programmers loathe, detest, and downright dislike code reviews, but there’s no reason to hate them. In fact, experienced programmers look forward to code reviews. We’ll see why shortly.

Person and perspective

The reason so many code reviews go bad is because the programmer makes a connection between their code’s worth and their self-worth. When reviewers point out problems in the code, the programmer takes it as an insult and gets defensive, and things go downhill quickly.

Let’s be very clear about this: reviewers will find fault in our code. That does not mean that we are bad at coding. There’s always room for improvement, or at least different perspectives, on how our code should be written. We must treat the code review as an open discussion, not a trial where we’re the defendant.

Faults can range from bugs to issues of style. The bugs are easy; we have to fix them. Everyone, novice and expert alike, can make mistakes now and then., Just take notes and move on.

The more contentious problems arise with issues of style. Maybe we’re using a loop with a counter, and when a senior programmer reviews our work suggests using an iterator instead. Is your code wrong and the suggestion right? No, matters of style are not so absolute.

Since this is an open ...