The Goal: Better Code, Not Bigger Egos
A code review is a dialogue about the code, not a judgment of the author. The primary goal is to improve the quality of the codebase. A secondary goal is to share knowledge and elevate the team. It should always be a positive and collaborative process.
How to Give Effective Feedback
- Comment on the Code, Not the Coder:
- Bad: "Why did you write it this way? You forgot to handle the error."
- Good: "What's the reasoning behind this approach? It looks like this path doesn't handle the error state."
- Be Specific and Actionable: Don't just say "This is confusing." Explain what is confusing and suggest a clearer alternative.
- Use the "Suggestion" Feature: On platforms like GitHub, you can suggest a specific code change that the author can accept with one click. This is incredibly helpful.
- Automate the Nitpicks: Use linters and formatters to automatically enforce style conventions. A code review should focus on logic and architecture, not debates about semicolon placement.
- Praise in Public: If you see a particularly clever solution or a great piece of code, call it out! Positive reinforcement is powerful.
How to Receive Feedback
- Assume Good Intent: Your teammate is trying to help you and the project. Don't take comments personally.
- Be a Learner, Not a Defender: Your first instinct might be to defend your choices. Instead, take a breath and try to understand the reviewer's perspective. Ask clarifying questions.
- Don't Argue in the Comments: If a discussion goes back and forth more than twice, it's time for a quick call or a face-to-face conversation. Text is a poor medium for nuanced debate.
- Show Gratitude: Thank your reviewers for their time and effort. A good review takes significant mental energy.