A lot of companies perform code reviews but the meaning of what a code review is doesn’t seem to be standardized. Some places copy/paste some code into word documents and pass it around (no joke, I have seen this), other places do group reviews in front of a large screen, etc.
The process I prefer is a systematic code review of each and every commit. I am currently doing this via github and Jira, but I’ve done it before with subversion and Test Track Pro. It works just as well.
Some developer works on a feature related to multiple commits, you are assigned the ticket for review.
- Compile a list of all the commits related to the ticket and sort them from oldest to newest. We will start the review at the same place as he started coding, that way we can understand what he was doing and follow the changes.
- Look at the commit message, it should indicate what the work was about. If it doesn’t write a note.
- Look at the changes in the commit, there should be a single change that is easy to follow. If this is not the case, write a note.
- Does the code have a unit test? Does the unit test run?
- Look at the tests, can you understand what it is asserting?
- Are the tests testing desired outcome or implementation details?
- Is the code easy to understand? If it’s easy for you to understand during the code review it will be easy to understand when you are maintaining it.
- Where the correct commands used? Take the time to understand the implications of every command. If you don’t know in detail what a command does, read the documentation, dig into the command code.
- What do the variable names look like? Do they convey what the variable is?
- What about method names? Do they make sense?
- Are the methods small? Less than 6 lines?
- Does the new code respect the SOLID principles? Refresh your memory on the subject.
- Is there a design pattern that can be used to solve the problem more elegantly? Refresh your memory on the design patterns
- What is the scalability impact of the new algorithm? O(n!)..O(1)? Is that correct?
- Are there any comments that imply a new method could be created?
- Is there any commented out code?
A code review is an opportunity for you to learn and to improve the code you are working on. It also gives you the opportunity to teach what you have learned to a fellow team member.
The initial weeks when I started working at the first company where my code was being systematically reviewed it was a big hit on my ego. Eventually I realized the benefit and now I look forward to being reviewed. By reviewing code, I also learned to keep my commits small and my code easy to read.
Advertisement