Code review is nothing but the examination of checking of the code written by one developer by another, to see if there are any errors, or if anything can be made better. In the normal case, developers write code on their own, and once they are done, submit it for review. Over the years , we have found this process to be extremely valuable in producing code that is almost completely error-free. Here are our tips for effective review:
Everyone should review
There shouldn’t be one team just to write code and another to only review – though some may be better at it than others, maintaining a positive attitude within the team makes this step important. No one team is burdened with only writing or only reviewing, and all are seen as equals – though of course, the senior members can be given some weightage.
Review the Entire Code
Even if you think it’s a small or simple piece of code, make sure to review it, and don’t leave anything out. This way, code review becomes an integral part of the process of code development.
Adopt a positive attitude
Reviewers and coders need to maintain a positive attitude – it’s neither the time for one-upmanship, nor the time to be defensive and take it personally. Reviewers should offer constructive criticism, and coders should take it as such.
Reviewers should ideally review short snippets more frequently
This is to avoid fatigue setting in. After about an hour or so, your efficiency will start declining. So it’s a wise idea to set aside a time for code review every day – maybe an hour in the morning, and include breaks as well. This way the coders will also be able fix problems quicker as the code is still fresh in their minds. Here are some bonus tips:
- It’s not necessary that you MUST find problems in every review – if it’s all ok, say so
- Use a checklist to ensure consistency, all the important stuff is covered, and that common mistakes are avoided.
Coders should submit shorter code and provide context.
Keep the code to around 200-300 lines maximum – the efficiency of review starts dropping significantly. Coders would also do well to provide context by linking to related specs or tickets with the help of code review tools. Short messages throughout the code that are useful to the reviewer will not only make their job easier, but will also result in fewer problems being pointed out to you.