Refactoring estimation


As every team that cares for quality and agility, we (the NDepend team) are
constantly refactoring the code we modify. Since NDepend became a professional
tool (feb 2007), it is mandatory to cover at least 98% of the code refactored
with automatic tests. Of course 100% is prefereable but it is sometime not reachable because of some specific features such as code that popups some MessageBox or code that is specific to .NET 1.0.


Since the beginning, we are measuring our refactoring productivity and my
personnal number is 180: in average I’m able to refactor and write tests for 180
lines of C# code a day. With experience, I’m learning to distinguish between
hard and easy refactoring. My guess mainly depends on following factors:

  • existing test coverage,
  • existing object model,
  • coupling between the code to refactor and the rest of the code.
  • number of feature to add during the refactoring.
  • number of bugs corrected in the code to refactor,


For hard refactoring, I estimate that I will refactor just 100 lines of
code a day. For easy one, it can goes up to 400. The important point is to keep a trace of the estimation and of the time actually spent to get better estimations in the future.


As a result, I now know precisely how long it will take to refactor a portion
of our code base before actually doing it. My opinion is that it relieves a lot of stress.



This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • Mario

    Thanks for publishing your metrics, Patrick. How many lines of code do you produce on a typical day? I’m trying to determine the ratio of refactoring to LOC. Thanks.