Productive Code Reviews


As a professional programmer, one of the things you will eventually have to deal with is code reviews. A code review is defined as:

The systematic examination (sometimes referred to as peer review) of computer source code. It is intended to find mistakes overlooked in the initial development phase, improving the overall quality of software. Reviews are done in various forms such as pair programming, informal walkthroughs, and formal inspections.

This means you code will be given to someone to read through and make comments about your development effort.

Why Have Code Reviews?

As you consider this approach, you need to take a step back and think about why code reviews are an important part of the process. What are the reasons why a peer review of your code is so helpful in the development process:

  • Functionality Checkpoints – verify code performs the function and generating required output, and designed.
  • Avoid Introducing Bugs — Another developer can help identify any potential bugs, especially if  the focus of the review is on a small subset of the code.
  • Design Advice — The original developer may end up off track from any design standards that might exist, so a code review can often reveal this scenario and offer an opportunity to get the project back on target.
  • Educational Opportunity — The person reviewing the code may actually learn something they didn’t know. It is also possible that the reviewed might see something that creates a learning opportunity for the person who wrote the code. When the development team works together, code reviews can be beneficial to the entire team.

Why Not Have Code Reviews?

Code reviews are seen by some developers as a negative experience. What are the reasons your team should not participate in the core review process:

  • Expensive – It costs money to pull a developer away from writing code to review someone else’s work.
  • Takes Time — The process consumes time from developers who are not writing code, which can mean the project timeline is extended because the length of the required code review cycles.
  • Too Personal — Criticism is not easy for most people, and code reviews can be a very personal business. When you have to volunteer your code to go under a microscope for everyone to read and make comments, it might be difficult to hear the input from those reviewers. These reviews can put strain on interpersonal team relationships, so it is important to make sure any comments or suggestions made are constructive in nature and never personal.

Types of Code Reviews

  • Email Thread – As soon as a given piece of source code is ready for review, the source is sent around to the appropriate colleagues via email for each of them to review as soon as their other assignments allow. While this approach can certainly be more flexible and adaptive than more traditional techniques, such as getting five people together in a room for a code-inspection meeting.
  • Pair Programming – As one of the hallmarks of Extreme Programming (XP), this approach to writing software puts developers side-by-side, working on the code together and checking each other’s source as they work. It’s a good way for senior developers to mentor junior colleagues, and often to adds the code review process directly into the daily programming process.
  •  Over-the-Shoulder – More comfortable for most developers than XP’s pair programming, the old over-the-shoulder technique is often the most intuitive and easiest way to engage the development team in regular code reviews. This informal approach is certainly simplistic but it can be a little too lightweight if it lacks documentation of methods and results.
  • Tool-Assisted – There is arguably no simpler and more efficient way to review code than through software-based code review tools, some of which are browser-based or seamlessly integrate within a variety of standard IDE and SCM development frameworks. Some tools also allow requirements documents to be reviewed and revised and, significantly, can also generate key usage statistics, providing the audit trials and review metrics needed for process improvement and compliance reporting.

Code reviews are an important part of professional software development, but only if you do it the correct way.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.