Refactoring

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; ...

Get The Agile Developer's Handbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.