Refactoring, Improving the Design of Existing Code

Chapter 01: Refactoring, a First Example

When you find you have to add a feature to a program, and the program’s code is not structured in a convenient way to add the feature, first refactor the program to make it easy to add the feature, then add the feature.

  1. Write test to ensure you’re not breaking the existing code.
  2. Split big methods in small ones in order to make them more manageable.