4.5. Refactoring

  • Reasons for refactoring

    • software entropy

    • you will not write perfect software, but you can make it better

    • starting with a blank slate is not the usual situation

    • refactoring is an essential part of test-driven development (see Testing)

  • Important strategies

    • have tests in place

    • use an IDE that supports you

    • be conservative and careful

    • if you have no tests in place: start breaking dependencies and introducing tests

  • Support from the IDE (demonstrates what differentiates a good from a less good IDE)

  • The relation between refactoring and optimising

    • Refactoring: changing code for better readability

    • Optimising: changing code for better peformance (usually impairs readability)

References: [Fowler, 1999], [Feathers, 2005], [Demeyer et al., 2003]