In the era of rapid development and agile model maintaining quality of the code base is always challenging for every organization and teams. Code review plays an important role to maintain the code base clean and good. It should be always a two way healthy debate between the developer and the reviewer, which will results a lot more better result to code base as well as the entire team.
During my initial days of coding code review is the process of getting your senior developer/lead/architect time so that they can sit at you machine and verify the changes and tell their comments. This includes healthy discussion and debate on the code as well. Once they approved only we were able to check in/commit the changes.
Now we do have different tools and creating a pull request , the reviewers can review the code and add their review comments and you can resolve the comments as well.
In both cases always do a self review before you are assigning your pull request to a reviewer. You can create a self review check list in the team and follow the same which should include
- Make sure you are aware , judiciously following and verifying the principles like DRY (Do not repeat your self) , KISS (Keep it simple and short) , Single Responsibility Principle etc.
- Coding standards – the standards depends on your language and chosen by the team.
- Naming conventions and standard – always good to write code which is self explainable without comments also the case standards your team following .
- Best practices – Make sure you are following the best practices based on your language, class library and the frame work.
- Format your code – so that it looks beautiful – make sure that you follow proper spacing, indentation ( there are tools and shortcuts available for doing this in all modern editors) so that your code looks neat and clean.
- Make sure to run the unit test and all pass , run lint / code analysis tools and correct all errors and warnings.
Reviewers should be always open for discussion and understand the view of the developer and you should have healthy debate with pros and cons of both your approach and developer approach. This will improve the morale of the entire team as well as knowledge.
Do a full review and add all comments in advance so that the developer can resolve all comments at once. Make sure to consider all aspects of the code including the impact on the current functionalities as well. Also consider all the principles , anything missed from the self review checklist.
Also encourage the peer review before the senior level review so that the efficiency and quality of entire team shall improve. This will help to build the next level of the team and you can follow the code quality religiously across the team.
Happy code review 🙂