How to give code review feedback?

Code review helps you to improve the quality and maintainability of your code. However, this process is challenging for both engineering managers and developers. While managers need to perform thorough reviews to ensure code quality, developers are usually overwhelmed when receiving feedback. 

Engineering managers need to be courteous and respectful while offering constructive feedback to their developers. They must be clear with their feedback so that developers can understand your feedback in the right way and not take it negatively. 

In this blog post, let’s explore the ways to provide code review feedback to developers: 

What is code review?

Also known as peer review, code review is a key practice within quality assurance. It is a systematic examination of a software code by one or more individuals to improve its quality, identify issues, and ensure that it aligns with established coding standards and best practices.

Why code reviews are important?

Catches issues early

Code reviews allow engineering managers and developers to detect issues and bugs in the early stages. So that the problems can be fixed before the end-users see them. Besides this, It allows developers to work with fresh knowledge, or else they may struggle to remember code, solutions, and reasoning. 

Supports knowledge sharing

Reviewing code regularly allows developers to learn more reliable techniques and best practices. It helps in gaining valuable insights into diverse coding styles and problem-solving approaches. Code review also allows engineering managers to mentor junior developers and foster a culture of continuous learning and growth. 

Increases code readability

Regular code reviews ensure the entire team adheres to consistent coding standards and best practices. This makes it easier for developers to understand and contribute to the codebase. Hence, they can write more readable and maintainable code over time. Besides this, it provides opportunities for refactoring. 

Minimizes technical debt

Optimizing code through the code review process eliminates a significant amount of technical debt. It also detects code smells which are early signs of potential technical debt. Code reviews analyze the code and catch bugs to reduce the need for extensive rework later.

10 ways to provide code review feedback

Ask questions during the code review process

Always ask questions rather than demanding changes. It not only opens up a dialogue but also lets them think about input without being defensive. This also ensures that both parties can decide on the right course of action and know each other’s perspective. When asking questions, developers can explain their thought process and rationale behind the code. This also fosters a culture of collaboration and highlights that nobody is always right.

Example

Instead of saying ‘Change the variable name’, ask ‘I see you named this variable ‘Temp’. What about calling this variable ‘UserID’?  

Avoid using condescending words

It is seen that written constructive feedback is usually taken negatively. Since the individual cannot see the body language, facial expressions, or tone of the other person. Words like just, easy, and obvious may seem belittling to the developers. This not only diminishes confidence but also introduces ambiguity within the team. 

Make sure that you provide feedback in clear and complete language. And most importantly, Be polite! 

This will help developers grow and work efficiently. Hence, enhancing overall code quality. 

Example

Don’t say ‘This fix is way too easy’. Instead, use this ‘I see a straightforward implementation here. Can you walk me through your decision-making process?’ 

Focus on the code, not the developer

Address the code directly rather than the developer. Discuss what can be improved in the code, not the developer’s skills or characters. Blaming them will lead to judgments, rejections, and defensiveness. They would avoid taking feedback positively. 

Hence, ensure an objective evaluation of the code. Make this process a team sport and focus only on facts. 

This will not affect any interpersonal relationships within the team and developers will take feedback seriously.

Example

Instead of saying ‘You haven’t optimized the code efficiently’, You can say ‘This code hasn’t been optimized properly’. 

Explain the ‘Why’ behind the feedback

Instead of just telling what improvements to be made to pull requests or code, explain the reason behind the change. Let developers know about the thought process and reasoning so that they look from the other’s perspective. Add a brief explanation along with the change mentioned. 

Never assume that developers understand the ‘Why’ behind the change. Always clarify the reason so that they know where it is coming from. 

This will help developers improve their skills and knowledge, enhancing code quality. 

Example

Don’t say ‘Update the variable names’. Instead, say this ‘Try adding descriptive variable names to enhance code readability and make it easy for other developers to collaborate and maintain the codebase.’ 

Use ‘I’ statements

Clarify to developers that it is not a universal statement or generalization. Rather, it’s an observation or one perspective as per the code written. 

Hence, use ‘I’ while writing constructive feedback. It not only fosters an open and receptive environment for discussing code changes and improvements but also makes it easier for both sides to look for solutions. 

This makes developers less defensive about their work and more open to pair programming and learning opportunities. 

Example

‘The code is hard to follow’ should be changed to ‘I am finding this flow of code a bit challenging to follow.’ 

Suggest solutions

Always suggest solutions and guidance on how they can improve. It could be a framework, method, or API. It doesn’t mean giving a complete solution but sharing an improvement strategy. This will save developers time in implementing these suggestions and address issues (which they might have overlooked). Also, they will be able to learn new techniques, best practices, and coding standards to improve their coding skills. 

Use examples as well so they understand the solution practically. 

Example

If the loop structure is inefficient, suggest a solution like ‘Consider using a ‘for-each’ loop instead of a ‘for’ loop for better readability and concise code.’

Share learning resources

Apart from solutions, share learning resources with them. It could be related to the areas where developers need improvement, new industry trends, or code review best practices. It will help them stay updated with the current trends and improve their understanding of specific technologies and frameworks. Resources such as relevant documentation, tutorials, and online courses work wonders. 

This will help developers take ownership of their learning and foster a sense of autonomy.

Example

Instead of simply pointing out the developer’s blindspot, for example – Not familiar with the new framework’s syntax. Write this – ‘I noticed some challenges with the syntax of the new framework. I recommend checking this document ‘Framework Documentation.’ as it provides clear examples and explanations.’ 

Keep code reviews small

Review code frequently as it reduces the need to make the process lengthy. Long code reviews would be overwhelming and confusing for developers since they need to make a lot of changes and improvements altogether. Even after doing it frequently, the code reviews take hours, break it down into small parts. 

Smaller code reviews allow developers to understand the reason behind the constructive feedback. Hence, they can make changes to the code without any dilemma or misunderstanding. 

Example

Suppose a developer has submitted a large pull request that considers various features and changes. 

Instead of sharing feedback all at once, say this ‘Let’s first focus on the changes related to the new feature implementation. Once done, we can move on to reviewing the improvements in the existing code.’ 

Appreciate your developers

Effective code reviews take place when both positive and constructive feedback is included. Developers may make a few mistakes here and there. But, this doesn’t come from a bad place. They are improving, growing, and giving their best. 

Hence, pat their backs on the things they have done correctly. Positive feedback creates a culture of recognition and gratitude which improves collaboration and communication. 

This also lets development teams to continue put efforts and strive for excellence.

Example

When recognizing their efforts, say this ‘Nice job on the new feature. Your attention to detail and writing readable code is commendable.’  

Use automated code review tools

Use code review tools to help in assessing the quality of code. These tools can help in spotting bugs and vulnerabilities, detecting code smells, syntax errors, security vulnerabilities, and many more. It also gives visibility into changes, hence, making the feedback more focused and contextually relevant. 

These tools also ensure that the code adheres to the coding standards and best practices. 

Typo: Automated code review tool

Typo’s automated code review tool identifies issues in your code and auto-fixes them before you merge to master. This means less time reviewing and more time for important tasks. It keeps your code error-free, making the whole process faster and smoother.

Key features:

  • Supports top 8 languages including C++ and C#
  • Understands the context of the code and fixes issues accurately
  • Optimizes code efficiently
  • Provides automated debugging with detailed explanations
  • Standardizes code and reduces the risk of a security breach



To know more about this feature, Book your demo today

Conclusion

The code review process might be time-consuming, but, it is rewarding too. It helps in knowing whether the code needs refactoring, has bugs or errors, or anything else that could hamper its performance. 

Follow the 10 tips mentioned above to encourage collaboration, open communication, and knowledge sharing among developers. 

Happy reviewing!