Code reviews do not only improve the quality of code but are a great tool to learn from others and share experience. Doing and having code reviews is not an easy task. Pointing to or criticizing your colleagues and peers is not something someone would like to do daily. Therefore, doing it in a constructive and positive manner would be beneficial to both the reviewer and reviewee.
- Adhere to coding guideline or make one with your team members.
Use the right words:
- Avoid using negative words and comments like "Remove", "Change", "Not needed", "No", "Bad", "I don't like this" etc...
- Don't use sarcasm.
- Avoid referring to code as "mine", "yours", or "theirs".
- Ask questions instead of giving orders. Use questions like "Do you think this would be better?", "What do you think about...?"
- Be positive. Don't say words like "I didn't do this", "It wasn't me" etc...
- Explain the reason behind your comment and how it will improve the code.
- Express yourself clearly and provide arguments. If needed, link to other code snippets or PRs.
- Ask for clarification if the code is unclear. If there are too many questions it would be better asking them in person.
- Be clear in the feedback. If a lot of discussion is needed it can be done in a different session.
- Learn from the comments and how others tackle the same problem.
- Don't take it personal, code reviews are about the code and not you as a person.
- Accept all feedback. Whether you are a Junior or Senior take feedback positively.
- Be open to other ways of writing code or methods.
- Don't turn the feedback into an ongoing argument. You can always talk to the commenter in person.
- Be supportive. Help by pair-programming or showing an example.
- Be responsive. Provide more information or clarification in the same day or after one day.
- Be quick. Don't leave too many PRs open. The codebase will grow, and the PR will be behind.
- Give positive feedback when the PR is accepted, like using the Like emoji or saying words like "Great, well done".
- If a feedback helps, inform the reviewer how you find that helpful. Use words like "Good catch, thank you" etc...
Having a constructive and positive code of conduct will foster a healthy work culture and allow team members to express themselves freely without the worry of shame and negative feedback. This will create an environment where team members feel respected, valued and productive. At the end it will allow an agile environment, knowledge sharing and growth.