Code Review

The purpose of a code review is to have another developer provide a fresh set of eyes when looking at the code. The reviewer will be looking to not only verify the code functions correctly, but to aslo ensure that coding standards are met, as well as make sure that nothing malicious is contained in the code.

The ideal reviewer will have a good understanding of what the requirements of the code are, as well as an understanding of the details used to implement the requirements. For more complicated pieces of code, it may be necessary to have multiple reviewers to cover all of the aspects. For example, one developer writes a piece of code that calls two external systems. The code review may need to have not only the primary reviewer, but another reviewer for each system that is being called. These extra reviewers are to ensure that the code under review are actually calling the external systems correctly.

Coding Standards

Coding standards may be as simple as as using the formatting style that a language typically uses, to a complicated set of rules that digs down into minutia such as where a comma is to be placed. By following a standard, we are able to ensure that all code is written in a consistent style. The end result is that anyone opening a random file will be able to look at that file, and have a fair idea of what to expect in it.

Beyond being a formatting and style guide, a set of coding standards may also contain a set of best practices. These conventions may be used to identify common pitfalls, and how to avoid them as well. Note: if a best practice is listed in a coding standard, it needs to list why it is in the standard. This way, a developer will gain a better understanding of what the issue is, as well as how to avoid it. In the event that underlying rule or assumption changes, everyone will be able to better understand how the rule needs to be changed.

Additional Thoughts

The focus of a code review and coding standards should always be to provide constructive criticism. If a bug is found, the reviewer should not simply say that it is wrong, but why it is wrong, as well as how to fix it.

When doing a code review, it is very easy to fall into the trap where we focus on the standards too much. The end result of this is someone is discussing the capitalization of a variable, and missing the fact the logic the variable is being used in has a flaw.

Always remember, the purpose of code reviews and standards is to help create better code, not enforce arbitrary dictates.

Keywords to Search for

Copyright © 2018 Adin H. Baber, all rights reserved.