Anatomy of a Rewrite

For the past 6 months I have been working on a beastly 15,000 line .NET application. Spaghetti code with tons of redundancy (Copy&Paste gone wild). I have cleaned up all the existing code and added over a hundred new pieces of functionality (ranging from the cosmetic to major surgery). During this time I have kept some statistics to do with the size and nature of the application.

Despite the addition of all the new functionality just by removing the redundancy I have reduced the total number of semicolons in the application (my rather daft rule-of-thumb for size of the code) from nearly 15,000 to just a shade over 10,000. That’s despite adding nearly three hundred unit tests, extensive logging and the new functionality.

Graph of Program Statistics Over Time

Graph of program statistics over time

This graph shows how the various elements I tracked varied in relation to each other. The figures are rated from 0 (lowest for that category) to 1 (highest for that category).

  • Newline – the number of newline applications in the program.
  • Semicolon – the number of semicolons in the program.
  • XXX – the number of items that are known to be bogus but not broken.
  • FIXME – the number of items that known to be broken.
  • public class – the number of public classes in the program.
  • Unit Tests – the number of unit tests (using NUnit) in the program

It is interesting (to me anyway) to note the near-constant decline of semicolons while newlines have risen from a mid-project low to be at their highest at the end.

Start and End Statistics

Start and End Statistics for .NET Rewrite
Item Start Value (July 2003) (Near) End Value (February 2004)
Newlines 33,121 39,800
Semicolons 14,230 10,316
XXX 136 542
FIXME 1 63
public classes 73 180
Unit Tests 0 275

Succinctness is Power

Is this evidence for Paul Graham’s assertion that Succinctness is Power? I’m not sure I can count my changes as succinctness as they have added quite a lot of newlines and over a hundred new classes.

Comment on this article

One Reply to “Anatomy of a Rewrite”

  1. Pingback: Anatomy of a Rewrite -

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.