Home > General > About Code Review

About Code Review

December 12, 2009 Leave a comment Go to comments

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.

  1. Vaibhav Palan
    December 15, 2009 at 12:56 pm

    I feel developer should do the code review before unit testing and code should be reviewed by peer or code reviewer after unit testing..

    • Nayan
      December 18, 2009 at 3:28 pm

      This is a good thought… but I would still say that peer review should be done before complete unit testing is done. There is a high risk of rework incase major issues are found in unit testing.

  2. 00042730
    December 18, 2009 at 7:06 pm

    Code Review should be done after Unit Testing:
    1.Planning and implementing Code review is not easy.
    If we say before Unit Testing, at what stage? we dont have a reference ponit.
    So after Unit Testing is a reference point.
    2. A not unit tested code is not a completed code and there is no guarantee that it has all the validations and features implemented(though there can be bugs after Unit Testing)
    atleast by giving the Unit Tested code the developer is saying i have done my part and we hope he will not change so much in the code after the review except for closing the review points.

    • Nayan
      December 27, 2009 at 3:20 pm

      Two excellent points for doing a code review after unit testing.. Thanks for the feedback.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: