CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Patrick Smacchia [MVP C#]


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.

 

 



About Patrick Smacchia

Patrick Smacchia is a Visual C# MVP involved in software development for over 15 years. After graduating in mathematics and computer science, he has worked on software in a variety of fields including stock exchange, airline ticket reservation system as well as a satellite base station at Alcatel. He's currently a software consultant and trainer on .NET technologies as well as the lead developer of the tool NDepend which provides numerous metrics and caveats on any compiled .NET application. He is the author of Practical .NET2 and C#2, a .NET book conceived from real world experience with 647 compilable code listings. Check out Devlicio.us!