About Code Review
If my blog is About Coding then I feel I should write something About Code Review. There is enough said on importance of code review and its benefits. In fact, the average defect detection rate for code review is 60%. This is higher than other defect detection techniques like unit testing, functional testing or integration testing.
Also, there is enough said on various measurement techniques for code review like defect detection rate, defect density or the one showed by this cartoon :-).
So rather than focusing on importance of code review or its measurement techniques, I would like to bring up a very universal question on code reviews… whether code review should be done before or after unit testing.
Benefits of doing code review before unit testing
- If a major issue is found during code review then there is less rework. Since unit testing is not done, the defects are identified at a earlier stage and effort is saved.
- Since the reviewers know that the unit testing is not done they expect code to be buggy and would identify more defects.
Benefits of doing code review after unit testing
- Since the unit testing is done, code is not crappy and many obvious mistakes are removed in unit testing stage.
- Less defects are identified & code review time is reduced.
- Developers are more comfortable sending their code after they have done the unit testing.
So, what do you think? My personal bias is on doing the code review before unit testing but a balanced approach can be made. If there are significant changes then a dual code review can be recommended. The first one can be done at a very high level before unit testing and a detailed code review can be done after unit testing. Alternatively, a single round of code review can be done after some amount of unit testing is done but not completed.