Code review is one of the many processes of software development. When someone writes code then someone else (project manager, developer, tester) will review the code written for potential errors. It is a very important step because it can prevent bugs, security holes, encourage good practices and can maintain the same “style of code” for the whole project. For someone to be able to make a good code review is important to know the whole structure of the project and have a proper knowledge of the programming language he reviews. I will try to give some simple tips for better code reviews.
- Review the right things and let tools do the rest. You don’t need to check for code formatting since there are tools that do that. Ensuring that the code is correct, understandable and maintainable is what’s important.
- Adopt a positive attitude. Code reviews are not the time to get all alpha and exert your coding prowess. Nor do you need to get defensive. Go in to it with a positive attitude of constructive criticism and you can build trust around the process.
- Use a checklist. I find it useful to have a list with some important rules that i don’t want to forget when reviewing code. That ensures code consistency and maintainability.
- Provide solid examples. Don’t just point the issue but provide a good example that it’s not specific. Try to generalize the issue and give the developer to understand deeply the problem and the solution. That way you will limit the same common mistakes again and again.
- Don’t review too much code at the same time. You will eventually get lost in the business logic and you will not be as effective as possible.
- Explain why something need to change. Try to give statuses to your comments when reviewing. Some comments will be for security holes, others for performance and others for code maintainability. That way the development team when writing code will have in their minds those statuses and will try to actually write code that has all those standards.