• ABOUT
  • NEWSLETTER
  • Contact
Krzysztof Marczewski Krzysztof Marczewski
  • ABOUT
  • NEWSLETTER
  • Contact
  • Development
  • Productivity

Code reviews done right

  • Krzysztof Marczewski
  • 6 January 2021
  • 3 minute read

Behaviors to avoid in code reviews:
– stating opinion as fact
– avalanche of comments
– asking devs to fix problems they didn’t cause
– judgemental questions
– sarcasm@sandyaaaas #AlterConf pic.twitter.com/LX1AeG4JOk

— Rachel Thomas (@math_rachel) December 10, 2017

The above tweet has become an inspiration for this quick post. As a first thing, let’s clarify what we should not do during code review. @andyaaaas highlighted the top worst practices:

  • stating opinion as fact
  • avalanche of comments
  • asking devs to fix problems they didn’t cause
  • judgemental questions
  • sarcasm.

These tips come from “Unlearning toxic behaviors in a code review culture” based on a presentation with the same title. It’s worth to check them for more context.

Fortunately, at the Tigerspike, the company I’m currently working at I didn’t spot such behaviors. That is definitely great but doesn’t stop people from improving things. Here’s a list of good, unusual, and unobvious practices I’ve spotted during code reviews in Tigerspike:

  • labeling comments
  • explaining motivation
  • marking core changes
  • showing result
  • highlighting state

Let me uncover them in details:

As reviewer:

1. Label comments

Indicate your intentions by labeling your comment. Labels may also help to define if your suggestion is required or optional. It’s good to agree with the team on using a set of common labels for comments (using them for every comment is not required, but it’s super-handy).

Here’s an example of labels we’re currently using, but nothing stops you from creating your own set.

[GOOD TO HAVE]

(..comment with your suggestion of what reviewee may change, but it’s not blocking Pull Request from being merged..)

[QUESTION]

(..comment with a request for further explanation about the specific part of code/process behind, etc..)

[BLOCKER]

(..comment highlighting what and why need to be changed to get your approval..)

By the way: thanks for Tom Koptel, for bringing that idea to our daily code reviews.

As reviewee:

2. Explain motivation

When you feel some additional information for the reviewer may help in understanding or quicker approval, write it down in comment for a specific line. Reducing unknowns in complex code may result in fewer unnecessary and long threads. If you had a couple of ways to accomplish some tasks, and you’ve picked a specific one, it may be worth to write down your motivation — especially if you feel it may be an unpopular choice.

3. Mark core changes

Mark code with core changes in your pull request. Especially in larger PR, it’s beneficial as it increases understanding by your reviewers.

4. Show result

If code change is related to GUI/Design, one screenshot added to PR’s description will tell more than a thousand words.

5. Highlight the state of work

If your PR is in a work-in-progress state, highlight it with a comment or even include this fact to PR’s title. In that case, it’s also worth adding a to-do list with remaining work.

Conclusion

The preceding list is short and concise, but for me, that is its strength. — simplicity and pragmatism behind the scene. Implementing them may help you and your team in getting a better understanding of the code and intention of both sides, less frustration, and more efficient code reviews.


Thanks for your time!

Please let me know if you find it useful or if you have any questions/suggestions about improving code reviews.

If you’re interested in more content like this follow me on twitter

Total
0
Shares
0
0
0
0
Previous Article
  • Productivity
  • Tools

The best offline note-taking app

  • Krzysztof Marczewski
  • 17 January 2019
View Post
Next Article
  • Development

Android Studio Productivity Course

  • Krzysztof Marczewski
  • 6 January 2021
View Post

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

© 2024 by Krzysztof Marczewski

Input your search keywords and press Enter.

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Cookie settingsACCEPT
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT