I’ve grown to really appreciate code reviews. Like testing, code reviews allow you to catch bugs and improve code quality. But they also help teams find better, alternative options, and transfer knowledge between team members.
What follows is a list of non-technical practices to keep in mind for conducting effective code reviews. Some of these I want to start doing, some I already do, some I do but do poorly.
- Agree to a standard for reviews with the rest of the team. This is critical. If everyone on the team has different standards then reviews will be tough. A style guide and best practices document that the team creates is a huge help here.
- Remember, you are not your code. It is so easy to take criticism personally but do you best to avoid this. Everyone, no matter the skill level, has areas to improve on. Accept that and thankful that you have a team that can teach you things.
- Be kind. Don’t let the lack of face-to-face communication cause you to be harsh. It’s easy to fire out “you’re wrong” in a review and be harsher that you would face-to-face. But that is a great way to make someone defensive and not be receptive to criticism.
- Look for things people are doing right. Pointing out new an interesting things in a review is good way to encourage learning and build relationships.
- Be pragmatic and keep code moving. Sometimes people have differing opinions and no amount of discussion is going to change that. In that case, defer to a third party or take a vote as a team. Don’t let reviews get stuck in the mud.
- Give reasoning. Saying “change this” without a reason is not helpful and won’t prevent similar mistakes in the future. This also helps to keep reviews objective. It is too easy to let your personal preference come out in a review as the “right way”.
- Ask questions. I learn a lot through code reviews. Especially when we start using a new library or tool. If you aren’t understanding, ask the team to explain!
- Have a good attitude and assume good intent. Remember, you are all on the same team and are trying to create high quality software. Developers aren’t trying to come up with bad solutions. They may just not be aware of a better way.
If you aren’t conducting reviews yet I highly recommend it. Both Bitbucket and and Github make it incredibly easy. Any any slight slow down you might experience by always doing reviews will be more than made up for in much higher quality code and team members that are far more aware of the what is going on in different areas of the stack.