Performing a Better Code Review

Sunny Sharma
Software Development Manager

David Cross
Data Analyst

A Code Box with a checkmark

Performing a Better Code Review is the last of a larger 3-part series on Code Reviews. Now that we have gone over the “Importance of Code Reviews” and the “4 Different types of Code Reviews“, we help you perform a better code review. In this blog we discuss how to:

Being a Better Code Reviewer

To increase your Reviewer’s effectiveness, adopt the following:

  • Review no more that 400-500 Lines of Code at a time (4).
  • Review no more than 60 minutes at a time.
  • CR should be executed daily, and ideally at the same time of day.
  • Use checklists. Ex: Are all requirements met? Is the code unit tested?
    Are there security vulnerabilities?
  • Encourage asking questions about the code to the Author, instead of making statements.
  • Provide suggestions with your comments
  • Use Visual aids
  • Accept that there are different solutions to a problem.
  • It is acceptable to say that everything looks good and move on.
  • Objectively review the code, not the Author.

Use praise for good code. According to April, a reviewer should always keep this in mind: “Always ask yourself if your feedback is true, necessary and kind” April Wensel


Being a Better Code Author

As a code author, it is easy to get emotionally invested in your code. Keep these in mind to be more objective while doing CRs:

  • The code is not you. Detach yourself from your code and remember that the Reviewer is offering constructive criticism of the code and not yourself.
  • Be humble. Remember that you are both on the same side and want to achieve the same goal of well-written, concise, and error-free code.
  • Provide visual evidence of changes with screen prints and sample output. This is particularly the case when you have made UI changes. This can be in the form of before and after screen prints, or output examples. You are saving Reviewer time, and possible aggravation, if they do not have to execute an application to see what the changes are.
  • Be the first reviewer: Be your own critic. Before asking other to review, review your code by yourself.
  • Provide annotation for important changes.
  • Provide a concise title with a Tracking/Reference number
  • Describe the reason (the why) for the code change

Creating Code Review Governance

After your team has decided on a review type, we recommend you follow these guidelines to make your Code Reviews more effective. Here are the steps we took to creating our Code Review Governance.

Team Code Charter

Develop a Team Code Charter that utilizes quantified methods. For example, your charter might include the following Tenets:

  • Demand that code be developed iteratively. This enables early feedback and promotes a continuous testing and integration cycle.
  • Manage the requirements and realize that these are dynamic and constantly changing.

Best Practices

Develop and follow proven Best Practices with rules like the following.

  • Agreed upon naming conventions for variables, modules, and APIs, etc.
  • Indentation rules/style
  • Header information – comments

Compartmentalization

Compartmentalization of the code allows your team to find even the smallest details. It also prevents the Reviewer from becoming overwhelmed.

  • Break down code into components. This allows tasks to be divided up between team members.
  • visually model the software. There are many tools for this. The goal is to have a roadmap that everyone on the team can use as a reference.

Create a Review Template/Acceptance Criteria Checklist

From your chosen method (based on your organization’s work practises and structure), create a Review Template. This serves as a guideline for newly onboarded members too when they know what is expected of them.

As part of this template, a Code Acceptance Criteria Checklist should be included. For example, in the checklist, you can ask the reviewer questions like this:

  • Is the same code duplicated in another module?
  • Is the code serving more than one purpose? Code modules should have one purpose only.
  • Is the code module too big (too many lines of code/handling too many responsibilities)?

Automation

Make your teams life easier by automating processes where you can. It is always a good idea to automate mundane tasks like:

  • Linting. Use a linting program to find issues you might not see by eyeballing the code.
  • Create test scripts for unit testing and integration testing.

Quality Testing

Quality should be kept in mind at all times.  In the book ‘Understanding and Controlling Software Costs’ the Authors state that coding errors(bugs) are one hundred to one thousand times more costly to fix after deployment. The remedy is to be vigilant with security and quality while both coding and reviewing.


In Conclusion

To summarize, code reviews are an integral component in the Software Development Life Cycle. For Authors/Developers, creating code with the expectation that it will be rigorously reviewed, creates better code and developers. Best practise guidelines not only serve to orient new developers, but also assist in creating consistency.

For Reviewers, having a definitive roadmap to follow, allows them to concentrate on the task at hand. They can concentrate solely on Review without feeling ambiguous about what is expected of them.

The improvements resulting from good Code Reviews will be both immediate, and cumulative. Some gains will be realized right away, and some might not be seen for weeks or months.

Ultimately, good code reviews create a better product.


Performing Better Code Reviews: Free E-Book

Code Reviews 101: Ebook

If three blogs are too much to keep track of, we have turned our series of blogs on Code Reviews into a free downloadable E-Book:

  1. Introducing Code Reviews
  2. Choosing the Right Type of Code Review
  3. Performing a Better Code Review
  4. Code Review in Practice (Only in the E-Book)
  5. Conclusion and References


Professional IT Services

Indellient provides IT Services with expertise in Cloud Services, Application Development, Data & Analytics Solutions, DevOps Services and Training, and Cloud Managed Services. Contact our team for a no-obligation conversation on planning, executing, and maintaining your technical projects.

Learn More

About The Authors

Sunny Sharma

Hello, my name is Sunny Sharma, Software Development Manager at Indellient. The skill set I have developed is honed from over 7 years in the IT field, after completing my Master's program from University of Saskatchewan's Computer Science program. I have a passion for iterative development, architectural design and building highly scalable projects.

David Cross

Hello, my name is David Cross, Data Analyst at Indellient. The skill set I have developed is honed from over 20 years in the IT field, after graduating from Sheridan College's Systems Analyst program as a Sheridan Scholar. I have an enthusiasm for both Data Analytics, and the Extraction and Transformation of data between systems (ETL).