image-blog-vcs-how-to-do-code-reviews
June 4, 2020

How to Do Code Reviews

Code Review
Version Control

Code reviews can seem easy and straightforward. But they aren’t always. Here, we give an overview of what a code review is and the challenges that come with doing code reviews. Plus, we share tips on how to do code reviews — at scale.

What Is a Code Review?

A code review is an activity in which one or several team members review part of a program’s source code. It is typical to review all new or changed code.

Code reviews are important to improving quality by finding and fixing issues as early as possible. They can also ensure the consistency and reliability of the software you’re building.

Code reviews can also help productivity in several ways. It is cheaper to find issues earlier. And code reviews help cross-train and align the development team on how the product is built.

Why Code Reviews Are Important for DevOps

Code reviews are important for DevOps because they help teams achieve quality and speed to add more value to a product.

There isn’t a one size fits all approach to code review. There are different models for code reviews in DevOps depending on when it is done in the lifecycle of changes in the product.

A pre-commit code review can, for example, look like this:

  1. Code.
  2. Review.
  3. Commit.
  4. Done.

A post-commit code review looks like this:

  1. Code.
  2. Commit.
  3. Review.
  4. Done.

So, you could do a code review before code is committed to shared repository. You could do a code review after code is committed. Or you could do code reviews both before and after code is committed. If your product includes a build phase, you must also consider if the review should happen before or after the build.

Top Code Review Challenges

There can be many challenges to doing code reviews in addition to finding the right model. Particularly, when it comes to code reviews in large scale organizations. Code reviews tools are built to help address these challenges.

Scale

Code reviews for a small team and project might be straightforward. It can be as easy as simply asking a colleague to take a look at what you have written and give you a few verbal comments.

But as the team, projects, branches, and paths grow, there are challenges to doing good code reviews at scale balancing quality, consistency, and speed. Scale is not only about the number of people. It’s also about how many projects, branches, and paths there are — as you can see in the table below. At which scale do you operate?

 

Elements of Scale For Code Reviews

Size

People

Projects

Branches

Paths

Complexity Score

Small

300

100

3

3

900

Medium

1,000

300

10

3

9,000

Large

3,000

300

30

10

90,000

Extra Large

5,000

1,000

30

30

900,000

Massive

5,000+

3,000+

300+

100+

90,000,000+

 

Distributed Teams

It’s also a challenge to do code reviews with distributed and remote teams. It will be impossible to stay on top of what has been reviewed. This will become a source of waste in the process without appropriate tooling.

Cost of Mistakes

Code reviews can present different challenges based on what you’re building. For instance, in chip design, you have tape-out dates (the final phase of the design lifecycle). In this situation mistakes can be extremely expensive and must be avoided at all costs.

Variant Management

Another complexity at scale is variant management. The more variants your product has, the more complex the code review process risk becoming. Working with all of this at scale can be a challenge.

Traceability

Another challenge is establishing traceability. How can you prove what has been reviewed and by who and how the discussion that ended up with a certain solution? This can be extremely important in patent right discussions in regulated industries. It’s also important to identify the source of new issues.

Regulations

If you’re in a regulated industry like automotive, standards may define how code reviews should be done. Obviously, not following a regulation is not an option. But you might be able to find more efficient ways to comply than what your competitors do via a more efficient code review process.

Agility

Being Agile at scale can be difficult in all cases, but ensuring that the code review process is something speeding up rather than burdening the organization is essential.

You can compare it with the elephant being afraid of a small mouse. If you are the elephant in an industry in rapid change – how do you compete with fast moving smaller competitors? How do you make sure that you can move as fast and be as Agile — even though you are working at this massive scale?

[Related Blog: Code Review Best Practices]

 

How to Do Code Reviews at Scale For DevOps

Here’s how to do code reviews at scale for DevOps.

1. Choose the Right Tool

It’s important to choose the right code review tool for your team.

The right tool:

  • Doesn’t keep your colleagues waiting.
  • Gives you visibility into what’s going on.
  • Automates via workflows and integrations into other DevOps tools (version control, build automation, etc.)
  • Delivers feedback and automated notifications.

All of this is critical to overcome the challenges of doing code review at scale.

Helix Swarm, for instance, is the code review tool for Perforce Helix Core. It does all of the above and helps your team work as efficiently as possible.

2. Remember Reviewing Code is a Skill

Communication is critical in code reviews. It’s important to give clear feedback during code reviews to improve the overall quality of your product.

It’s also important that the team stays in the loop — and that you have visibility – throughout the process. This can be difficult when you deal with different time zones, and especially with everyone working out of the office. Being able to communicate clearly your review feedback is key to work efficiently.

Treat reviewing code as a skill. This is something your teams can be good or bad at. Invest in training the team to improve their feedback and review skills.

Using Helix Swarm will help your team members communicate, collaborate, and improve — even if everyone works from a different location.

3. Maintain a Single Source of Truth

Maintaining a single source of truth is just as important in code reviews as it is in version control.

You need to have a global review system that scales — and keeps everyone working on the latest versions of the code. If you don’t, it’s much harder to get a big picture — especially if you’re working with teams of 100s or 1,000s of people. When a change is ready to be built, you want that to happen as quickly as possible. So, it’s important to have your build farms well supported.

With Helix Swarm, you’ll be able to work effectively locally and scale globally. You’ll get visibility into what people are up to and what they’re doing. And your team will be able to work quickly to commit changes.

4. Integrate Your Toolset

Integrating your toolset is essential for doing code reviews at scale for DevOps. After all, code review and version control aren’t the only tools you’ll be using.

For example, you might be using Jenkins as your build runner. Jenkins can be integrated with Helix Swarm and Helix Core to ensure an efficient workflow for CI/CD.

Each team member submits their code for review. Once Jenkins reports that the build and tests have passed, Swarm notifies the team that changes are waiting to be reviewed and approved. Once approved, the code can be deployed automatically.

How to Make Good Code Reviews Better With Helix Swarm

You can make good code reviews even better by using Helix Swarm.

By using Helix Swarm, you’ll be able to conquer the code review challenges of:

  • Scale.
  • Distributed teams.
  • Cost of mistakes.
  • Variant management.
  • Traceability.
  • Regulations.
  • Agility.

Your team will be able to communicate better. You’ll get a single source of truth. And Helix Swarm is part of Helix Core. It integrates with Jenkins, Jira, and many other tools to make your code review workflows flow smoothly.

Ready to review code, collaborate faster, automate workflows, and monitor progress? Then get started with Helix Swarm today.

Already Using Helix Core?

You can download Helix Swarm for free.

Get Helix Swarm

 

Not Using Helix Core Yet?

You can try Helix Core with Helix Swarm for free for up to 5 users and 20 workspaces.

Try Helix Core + Helix Swarm