[Article] Giving and receiving code review

What is code review, and why do people use it?

:white_check_mark: What code review generally is: Presenting clean, properly-formatted, polished block of code for feedback on a specific question, usually in regard to code quality, readability, correctness, or security. Reading and offering clear feedback on someone else’s code.

:x: What it generally isn’t: Sharing an early draft of unformatted code, and/or asking reviewers to check for anything wrong with it. Sharing a final project and asking for feedback on the project itself (instead of a piece of the underlying code). Rewriting or marking up someone else’s code outside of their specific request.

Many resources on code review are specific to a particular coding language or to a work environment. See if you can identify the common principles in the overview articles below.

This post is a high level overview of why Palantir does code reviews, how to prepare code for review, and how to perform code reviews, as well as examples of a few different types of fixes. It’s a good intro to the topic as a whole.

This article outlines Netguru’s code review flow and highlights the tool that they use. Again, note the common principles with other companies and tools, and don’t feel obligated to use the tool this post mentions.

This article covers why businesses and organizations like to conduct code review and peer review of code. To be clear, including this piece here is not an official endorsement of the product by Codecademy.

Finally, we refer you to this list from the Wikipedia article on code review for this helpful list of purposes for code review.

  • Better code quality – improve internal code quality and maintainability (readability, uniformity, understandability)
  • Finding defects – improve quality regarding external aspects, especially correctness, but also find performance problems, security vulnerabilities, injected malware, etc.
  • Learning/Knowledge transfer – help in transferring knowledge about the codebase, solution approaches, expectations regarding quality, etc; both to the reviewers as well as to the author
  • Increase sense of mutual responsibility – increase a sense of collective code ownership and solidarity
  • Finding better solutions – generate ideas for new and better solutions and ideas that transcend the specific code at hand.
  • Complying to QA guidelines – Code reviews are mandatory in some contexts, e.g., air traffic software

How to review code

In order to maximize both the reviewer’s time and the efficacy of the review itself, there are several guidelines to follow in reviewing code.

:pushpin: We’re presenting this section before the “asking for code review” section because we think that grasping what the reviewer will be doing and looking for will help you prepare your own code for review and better understand what to ask for.

Start with this Codecademy video on how to review others’ code, and then take a look at the articles below.

This is a well-organized, comprehensive look at code review best practices. Not surprising, since it comes from Google’s Engineering team! We recommend reviewing this article now and consulting it again later on to make sure you’re still on track with the principles of conducting code review.

A practical, tactical guide to reviewing code. Once you’ve reviewed the principles above, this guide will help you outline how you actually do the review, with tips on everything from how many lines of code to review at a time to building a positive peer review culture. As a bonus, there’s a link at the bottom of the page to a webinar on the “Best Kept Secrets of Code Review.”

This also falls into the “tactical guide” category of resources, as one developer walks you through his method of efficiently reviewing others’ code.

How to write your comments on the code that you are reviewing is an important skill, and this article provides great examples of what to do (and some advice on how to deal with naysayers).

The “issues” feature in GitHub is incredibly useful for providing feedback on certain parts of a code base.

Asking for code review

Following the guidelines of the code review section of the /learnprogramming reddit FAQ is a good place to start.

Its do’s and don’ts can be applied almost anywhere that you ask for help, especially if you ask in a public forum. There are online communities where you can ask for code review, but as you can imagine, they most often respond to people whose code and request come across as prepared and mindful of the reviewer’s time. Again, we’ve found that the most pertinent advice here is to be specific with what you want to be reviewed – don’t just send over your entire site and repo and ask for general feedback, point people to smaller parts of your work or isolatable things that you’re trying to accomplish. After all, code review in the workplace doesn’t involve reviewing code for an entire project, they’re split up in smaller, digestible chunks like pull requests.

On that note, with a multi-person project, you can create a Pull Request on Github and ask for review there. Note that you’ll create a Pull Request to ask a specific person to review your code on Github. You can also post your code for strangers to review on Reddit, provided you follow the guidelines above. You or ask on the Stack Exchange forum specifically created for code review.

If you’re a beginner, we’d recommend sticking to the above locations at first. If you’re a more experienced coder who already has been active on Stack Overflow, that may also be a good place to ask for a review.

A special thank you to Codecademy Product Manager, @oduffy, for compiling these resources and drafting this article!

45 Likes

Great article! A quick question - specifically in context to the google article (How to Do Code Review), what is the meaning of the CL abbreviation?

3 Likes

Change List, similar to a Pull Request.

5 Likes

Well detailed article. I never thought there’s so much involved in reviewing code. Thank you, this certainly has provided me with a good perspective on how to review code and why.

3 Likes

First link [Code Review Best Practices] doesn’t work :frowning:

1 Like

Hey, @alexanderlipko555505 I just checked the link… works ok for me! Can you try again?

1 Like

Hey, I just tried to open it with Google Chrome instead of Yandex browser and it worked fine. Access was denied because of security protection from online attacks (Error 1020). Thanks for your response!

1 Like

The first link doesn’t work. I tried a lot.

I just found out that the first link doesn’t work in every country. I tried to open it with a VPN and it works fine.

Hello, I am looking for someone to do code review with me. I have completed 24% of the learning path, live in Europe, and thank you in advance.

Hi, I’m Mauro and i’m doing the Data Science Foundations Skill Path coz i dont know which area i like more.

% of the path complete: 34%
Timezone: GMT-3 (Argentina)
One fun fact about yourself: love listen music, play basket and futbol.

1 Like

Hi, my name is Mauricio Ricaldi, I’m from Lima - Peru and I’m taking the front end engineer career path.
% of the path completed: 12%
Timezone: GMT-5(Peru)
One fun fact about myself: Love cooking, reading and writting. But most important, go out for a stroll with my doggies.

Hey everyone, where would be the best place to find someone to review code with?

kindly DM me on my instagram
Here is the link : https://www.instagram.com/musket_simon/

Hello, my name is Deborah, I’m looking for someone who can review my code, I’m Brazilian and I live in Europe, I wish you all a good job

Hey Deborah, I’m brazillian too!

Did you find someone do pair with you?

hei! I still haven’t found someone, if you want you can be my partner

Hey! I’m on Data Science Foundations Skill Path (44%). Time-zone is GMT+3 (but it is not a big deal for me). I’m looking a code review mate.

Hello! I’m Peregrine, and I’m currently 43% of the way through Data Science Foundations (and interested in the Machine Learning career path). Timezone is GMT+2. Happy to review code or have code reviewed, either sounds like a great way to go into more depth.

Oh, and one random fun fact about myself… coffee makes me sleepy so I don’t drink it when I need energy haha

Hi everyone! My name is Balazs living in Hungary, Budapest. I am currently 25% of the Data Scientist: M.L. Path. I am interested in using Python, SQLite, Pandas, and Numpy, and writing Automated Tests. I am a beginner right now but developing. Finishing this Path got priority and learning as much as possible during this journey is almost above all. I am looking for someone who needs a teammate to review each other’s or other learners’ codes. Fun fact: I like eating and I like sports at the same time despite the fact that I am not good enough at the second one right now. :grin: