Code reviews in a nutshell
Tags: codereview, pullrequest
Published: 2021-08-05 15:41:15

<!-- wp:paragraph {"className":"excerpt"} -->
<p class="excerpt"><em>When you’re working on a specific field, it is extremely important to never lose focus. What are the basics of your work? Why does it matter? Why do you do what you do?<br><br>We have decided to step back a little and take a good hard look at code reviews as a concept, and think through the basics of the work, why it matters, and how it’s become a cornerstone of software development.</em></p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>What are code reviews?</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Some concepts are so ingrained in our day-to-day activities that we have a hard time defining them precisely. A code review is one of them. A lot of confusion arises from this. One of the most common misconceptions about code reviews is that they are the same as pull requests.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>This is false.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Not only are code reviews <strong>not pull requests</strong>, they can happen independently of them, and outside of version control systems, such as Git. These are all tools that make code reviews more effective and easier to perform, but they don’t define the practice.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Code reviews, or peer reviews, are any and all software quality assurance activities where a person (or persons) that is not the original creator of the code will verify it by reading it.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>That’s it.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>It’s that simple.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Why do we need code reviews?</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>There are a ton of <a href="https://reviewpad.com/blog/automation-in-code-reviews-dos-and-donts/" target="_blank" rel="noreferrer noopener">automated processes</a> for reviewing code, correct? And there’s a lot to be said about <a href="https://reviewpad.com/blog/code-review-metrics-that-make-sense/" target="_blank" rel="noreferrer noopener">metrics</a> that can guide a review, which can also be systematised even by someone without a deep knowledge of the code, correct?</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>So why do we need some of our brighter development minds to be spending a significant amount of time poring over code that has already been tested and passed?</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For several reasons.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>We need code to be <strong>readable</strong>. When we are performing code reviews, we aren’t just debugging, we are doing an exercise in creative reading. We are checking to see if we can perfectly understand everything the code does. Every codebase needs to be updated, and it’s just not practical to always rely on the original developer to do so. The code needs to be readable by someone else.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>We need to transfer <strong>knowledge</strong>. A team that is composed of individuals that only understand the code they wrote is a team that doesn’t understand its own product. Code reviews aren’t just about improving the codebase, they are also about improving on what the team knows.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>We need <strong>continuous improvement</strong>, not just fixing problems. A code review shouldn’t just focus on picking bugs or defects. The reviewer is a second set of eyes and a second mind, and they always need to be thinking critically. Are there better solutions? Can we improve quality? Can this be done more efficiently?</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>We need it for <strong>team building</strong>. Collective ownership is key. The team needs to know that every single line of code is owned collectively by everyone, not just by the person who typed. Code reviews make the team understand that everyone can contribute with valuable input at any stage of development in a practical sense.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>So how do I do them?</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><a href="https://reviewpad.com/blog/continuous-code-reviews-are-the-way-to-go/" target="_blank" rel="noreferrer noopener">We have a lot of thoughts about best practices regarding code reviews</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>We understand not all of them are consensual, though, so here’s the bare minimum you <strong>need to do</strong> to implement an effective code review process with your team:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>Establish <strong>what to look for</strong>. Not all code reviews are born equal, and not all of them are looking for the same things. If you are making very minor changes to a function, for instance, you might not even need a review, even if it affects a significant number of files. Here are some things to look out for:<ul><li><em>Purpose</em>: Does the code do <strong>what</strong> it’s supposed to?</li><li><em>Requirements</em>: Does the code do <strong>everything</strong> it should?</li><li><em>Design</em>: Is the code readable and elegant?&nbsp;</li><li><em>Functionality</em>:&nbsp; Does the code serve its <strong>users</strong> adequately?</li><li><em>Complexity</em>: Could the code be <strong>simpler</strong>?</li></ul></li><li>Figure out <strong>how you are going to assign</strong> the reviews. Don’t just blast the whole team with a notification and have them randomly review things in their free time. Whether you’re assigning a senior and a junior developer or partnering developers in other ways, make sure reviews are assigned in a timely fashion to specific people.</li><li>Make sure reviews are done in a <strong>humane</strong> way. One of the major roadblocks teams face regarding code reviews is that people sometimes tend to not handle the emotional aspect of going over someone else’s work in the kindest way. Reviews need to be about <strong>collaboration, not competition</strong>. <a rel="noreferrer noopener" href="https://reviewpad.com/blog/are-code-reviews-hurting-your-team/" target="_blank">We were lucky enough to have a guest post on our blog about precisely this</a>.</li></ul>
<!-- /wp:list -->

<!-- wp:heading -->
<h2>If you are just getting started</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>We have made it our mission to improve code reviews, to make them more accessible and simpler for teams, and to truly make them an industry standard.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Reviewpad was designed to do exactly that, and you can try it for free.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><a href="https://reviewpad.com/get-started/">You can do it right now, in fact</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Let us know what you think.</p>
<!-- /wp:paragraph -->