Becoming a Good Code Reviewer

Why we need code reviews

  • Someone else can catch mistakes the author missed, helping us respond to side effects and errors early.
    • When you wrote the code yourself, you sometimes miss errors. They just don’t stand out ㅠㅅㅠ
    • The more people look, the more bugs we can find.
  • Following the team’s agreed conventions reduces technical debt and maintains product quality.
  • Keep up with each other’s work.
    • Follow one another’s work and check its progress.

What should we focus on?

  • From high-level concerns to low-level details.
    • High level: bugs, incidents, performance, security.
    • Low level: improving the design, renaming variables, clarifying comments.
  • Look at the context of the whole change, rather than individual small commits.

Things to keep in mind

  • Avoid reviewing the developer’s personality or tendencies.
  • Respect the scope of the review: lines outside the PR are outside its scope.

How should we leave comments?

  • Explain sufficiently why an improvement is needed, based on principles rather than opinions → the proposed change and the reason for it.
(X) You need to split this class into two.
(O) This class has two responsibilities. How about splitting it into two classes to follow SRP?
  • Explain objectively what could be done.
(X) This code is confusing (a "you" statement).
(O) I find this code difficult to understand.
  • Guide people toward clean, consistent code.
"You've used two ways of declaring functions: function expressions and function declarations.
Unless there's a particular reason, choose a declaration style yourself and follow that
convention. Consistent code is much easier to read and change.
Also, nice work using reduce to create a new data structure.
However, it's a shame that calculateEarningRate uses a for loop
for the same kind of iteration. Trying another higher-order function
similar to reduce could help keep the code more consistent."
  • Don’t review just for the sake of reviewing. If there’s nothing to improve, give praise.
The amount of code makes this easy to read.
I can see how much thought went into this.
This looks very efficient to me.
This seems much better than the previous code.
I like how thoroughly you've handled exceptions.
The function and variable names are intuitive.

The code review culture I want to build

- Anyone can review code, even someone who isn't a developer.
- Try to write code that even someone who isn't a developer can understand.
- A code review isn't a place to scold or blame someone for their choices. Having your code reviewed doesn't absolve you of responsibility, either.
- Code reviews let us check each other's mistakes and look for improvements together.
- Code reviews should be fun. Memes are welcome. Use them. I encourage it. Make it enjoyable.
- Reviewing someone more skilled than you is a chance to learn a lot from their code. It's fine to leave a comment like, "Wow, I didn't know you could do it this way!"

Let’s build an active code review culture.

Untitled


References

https://hyeon9mak.github.io/code-review-know-how/ (recommended)

https://tech.kakao.com/posts/498

https://tech.kakaopay.com/post/remote-work-code-review/