Improving the Design of Existing Code

by Martin Fowler

(with Kent Beck)

Refactoring is a controlled technique for improving the design of an existing code base. Its essence is applying a series of small behavior-preserving transformations, each of which "too small to be worth doing". However the cumulative effect of each of these transformations is quite significant. By doing them in small steps you reduce the risk of introducing errors. You also avoid having the system broken while you are carrying out the restructuring - which allows you to gradually refactor a system over an extended period of time.

My book describes the process of refactoring and spends most of its time explaining how to do the various refactorings - the behavior preserving transformations. The book opens with a simple example that describes the whole process. There are then some introductory chapters that discuss broader issues around refactoring, the “code smells” that suggest refactoring, and the role of testing.

The bulk of the book is around seventy refactorings described in detail: the motivation for doing them, mechanics of how to do them safely and a simple example.

This is the second edition of the book, published late in 2018. The first edition came out in 2000. This is the book that I'm proudest of, in that it's had a high impact on the world of software development. Several development environments now automate many of the refactorings described in the book. Refactoring has become a full-fledged part of the software development lexicon (sadly also leading to misuse).

For more background on the book, you can take a look at a couple of interviews I've done about it.


Notes for buying my books

Further Reading

Further resources on refactoring: in particular a catalog that includes summaries of all the refactorings in the book

Free Download of Opening Chapter

Changes for the 2nd Edition

Summarizes the changes between the first and second editions.

Errata (Second Edition)

How to access the web edition

Memos on writing the book

Thoughts about the book: including its scope, cover choice, target readers.

Errata for First Edition