Finding the time to refactor

  • Think of programming as writing code - that works, is easily readable and easy for other developers to modify and extend in the future.
  • In test-driven development, get used to thinking of a 'red-green-refactor' cycle. The green state ensures code passes tests, but the refactor ensures it stays clear and maintainable.
  • Make refactoring integral to every work schedule. Take a few minutes to clean up code, as soon as tests pass, with better names and extracting private methods and classes, etc.
  • Whenever adding a feature or fixing a bug, if you have to modify any piece of code that was hard to understand, refactor it right there and then.
  • When you try to introduce something new and the existing design does not work, refactor the design so the new addition is easier to make.
Make the change easy, then make the easy change. - Kent Beck

Full post here, 4 mins read