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 :doc:`test`)

* 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: :cite:`fowler-m-1999`, :cite:`feathers-mc-2005`, :cite:`demeyer-s-2003`