Sunday, March 12, 2017

Ground Rules for Refactoring Legacy Systems


If you have a very poor code which is buggy, cluttered, ugly, scary, etc. If you have such code,  do one of the following:
  1. Sunset this application
  2. Ask your customers to stop asking for changes and fixes
  3. Quit your job and switch to a more convenient one (other than software of course)
If you can't do any of these, then you're stuck with refactoring this code base. This is possible and even exciting.

Here is a set of ground rules to take into consideration before you start doing that:
  1. Zero "more" defects policy: That is, stop working the moment you find the next bug, and fix it immediately. The rule is adapted from the Zero defects policy! which is a bit overwhelming at this stage.
  2. Any "new" code must be covered by tests. Period.
  3. Peer review is part of our DNA (till we're able to automate parts of this review, or all of it)
  4. The Boy-Scout Rule applies to all of us. 
  5. Automate all donkey work, one script at a time! That is, everything we do in a systematic way, can be scripted. What we should do is to automate all this work. 
If you do that, you'll find things slightly improving at the beginning, but exponentially improving later on, insha'Allah :)

No comments: