In a nutshell, refactoring is the art of small and continual improvements to the design of our code while preserving its behavior. The intention is to create behavior-preserving transformations to our system which ultimately make it more maintainable.
Each time we change parts of our software, we purposely refactor parts of the code that are in our path. To ensure we preserve current behavior, we use automated tests which tell us if our code is still working as we refactor.
Using Ron's analogy of fields, thickets, and bushes from the previous section, instead of mowing around the bushes, with refactoring, we cut a path through each bush we encounter. It looks a little like the following:
We do need coding standards when refactoring; a good starting point is Clean Code: A Handbook of Agile Software Craftsmanship, by Robert "Uncle Bob" C. Martin. Coding...