What makes a code base hard to modify?

Kent Beck makes the following observations, in Martin Fowler’s book, Refactoring:

  • Code that is hard to read, is hard to understand and consequently hard to modify.
  • Programs with duplicated logic are hard to modify.
  • Programs that require additional functionality that requires changes to existing code are hard to modify.
  • Code containing complex and convoluted conditional logic is hard to modify.

When should you refactor?

  1. When you add functionality.
  2. When you need to fix a bug.
  3. When you perform code reviews.

When shouldn’t you refactor?

  1. When you really need to rewrite from scratch!
  2. When you are close to a release deadline.