Browse the Knowledge Hub211 resources
Refactoring: is it worth reading?
The catalogue of safe, named code transformations, and the argument that refactoring requires tests to be meaningful.
We earn nothing from any link on this page. No affiliate links anywhere in this library.
- published
- 2018
- key ideas
- 3

Refactoring
Improving the Design of Existing Code
by Martin Fowler
- Publisher
- Addison-Wesley
- Year
- 2018
- Edition
- Second edition, rewritten in JavaScript. The first edition from 1999 used Java.
- ISBN
- 9780134757599
Useful when you are: Practising tester, Senior / lead
Verdict
Should you read it?
Read it if
You review code, or you want to understand why a test suite coupled to implementation makes a codebase progressively harder to improve.
Skip it if
You do not read or write code. The relevance to testing is real but indirect.
The argument
What it argues
Refactoring is changing the structure of code without changing its behaviour. Fowler catalogues the transformations, each with a motivation, a mechanical procedure and an example, so that restructuring becomes a sequence of safe named moves rather than a risky rewrite.
The part relevant to testing is foundational: the entire discipline depends on having tests, because without them you cannot know whether behaviour was preserved. The book is explicit that refactoring without tests is just changing code and hoping.
The second edition rewrote the examples in JavaScript and reorganised substantially, which makes it more accessible than the Java original.
Key ideas
Ideas worth taking from it
- 01
Refactoring as behaviour-preserving change
A precise definition that distinguishes it from rewriting, and which only has meaning if tests exist to demonstrate the preservation.
- 02
Code smells
Named indicators that code needs attention: long method, feature envy, shotgun surgery. Shared vocabulary that makes code review specific rather than aesthetic.
- 03
Small steps with a green bar
Each refactoring is mechanical and small enough that the tests can be run after every one, so a mistake is caught immediately rather than discovered later.
Criticism
What has dated, and what it gets wrong
A catalogue, so it does not read straight through. Modern IDEs automate many of the mechanical steps, which makes the detailed procedures less necessary than they were, though understanding why each move is safe still matters.
Keep reading
What to read next
Reads well with
Reading about quality is cheaper than learning it in production.
QAble runs QA for products in BFSI, gaming, healthcare and SaaS, with engineers who have read these and argued about them. Start with a free QA audit.


