How To Do Code Reviews Like A Human (Code Review Soft Skills)
Tags: codereview, programming
Published: 2023-04-04 13:10:32

Most commonly, code reviews are focused on finding and fixing bugs in the code. However, it's also essential to recognize that code review **is not just about finding bugs**. It's an excellent opportunity for learning and bonding with your team. Focusing solely on bugs is missing the point. Instead, approach code review as a chance to learn from your colleagues, share knowledge, and grow as a team.

What is **not covered** in the popular code review advices:

- How is the author going to react to a list of defects?
- How do you help the author learn from their mistakes?

## **How to do code reviews like a human**
When reviewing code, it's important to remember that **you're working with human teammates who have emotions and a desire to learn and grow**. Effective code review should be viewed as an opportunity to provide constructive feedback that can help your teammates improve their coding skills and enhance the overall quality of the codebase. By taking a collaborative and supportive approach to code review, you can help foster a positive team culture that values continuous learning and improvement. Ultimately, this can lead to a more productive and fulfilling work environment where everyone feels valued and supported.

**1. Use a style guide to resolve style disputes**
- Recognize that debating code style can be time-consuming and subjective
- Choose to use a style guide to resolve style arguments once and for all
- Utilize an established style guide for the specific programming language being used
- Understand that no style guide is perfect for every project
- Deviate from the guide when necessary to meet unique project requirements
- Develop your own style incrementally to ensure both consistency and practicality

**2. Let automated tools do the boring parts**
- Acknowledge that time is a valuable resource in software development
- Utilize linters and formatters to automate the code review process as much as possible
- Minimize the number of issues requiring manual review and increase productivity
- Prioritize critical tasks by reducing the time spent on trivial issues
- Promote a healthier team dynamic by directing frustration towards automated tools instead of team members

**3. Be generous with code examples**
- Recognize the importance of working efficiently and collaborating effectively under time pressure
- Provide constructive feedback to your teammates during code reviews to demonstrate helpfulness
- Avoid being pedantic and acting solely as a gatekeeper
- Donate some of your own time to assist your teammate in improving their changelist
- Provide detailed explanations instead of general comments
- Include code snippets or examples to make your feedback more helpful and actionable

**4. Avoid using the word "you"**
- Avoid using "you" in comments when providing feedback
- Use "we" instead to reinforce team ownership and responsibility
- Emphasize that the code is a team effort, not just one individual's responsibility
- Use passive voice to focus on the code, rather than individuals
- Avoid using language that could trigger a defensive reaction

**5. Frame feedback as requests, not commands**
- Maintain a polite and respectful tone during code reviews
Use collaborative language to foster teamwork and equality within the team
- Frame feedback as a request rather than a command to encourage open discussion
- Acknowledge that you're not always right and encourage collaboration to find the best solution
- Avoid using bossy or subordinate language and aim for a respectful and collaborative approach

**6. Offer sincere praise**
- Look for opportunities to appreciate and learn from others' work during code reviews
- Take note of things that impress you, such as elegant solutions or effective refactoring
- Recognize the author's progress and improvements
- Approach code reviews with a positive and constructive mindset
- Foster trust between the author and reviewer by recognizing progress

**7. Strive to improve, don't strive to be perfect**
- Consider the patience and stress levels of developers during longer reviews
- Incrementally improve code quality by setting realistic benchmarks for improvement
- Avoid commenting out code that is not related to the changes made by the author
- Strive to build a culture of continuous improvement and excellence without overwhelming developers

**8. Take proactive steps to address stalemates**
- To handle stalemates in code review, aim to be proactive and avoid them as much as possible
- Watch for signs of tension or hostility, an increase in the number of notes per round, or pushback on many of your notes as these may indicate a potential stalemate
- If you sense a potential stalemate, consider remediation options such as talking it out, bringing the issue to a team design review, or conceding or escalating
- If a stalemate does occur, take steps to recover from it, such as talking to your manager or studying conflict resolution
- Aim for the ultimate goal - to find a resolution that satisfies both parties and allows the code review process to continue productively