Never Throw Away Old Code

source: Things You Should Never Do, Part I (joelonsoftware.com)

For many reasons, it is almost never a good idea to throw away old code. It may seem like a good idea to start from fresh if the existing code base is bloated, slow, hard to maintain, etc. However, by starting from fresh you are losing many many things. Some of the most notable reasons to keep your old code around are:

  • You may not do better the second time and what you've already done
  • The old code has been used and is (most likely) proven
  • You may lose out on days, weeks, months, or even years of bug fixes and testing
  • If its a commercial product, you lose out on your current market position/leadership

You might not even need to throw away the entire code base; you may be able to get away with rewriting/refactoring only certain parts of it. This could most likely be more efficient than starting over from nothing.

However, if your code is experimental or very small you may be able to more easily justify throwing it away. In these cases you would more easily be able to improve an algorithm(s) or implement new ideas (if starting from scratch).

Written on March 12, 2012