Definition of refactoring
Refactoring refers both to a technique and to each of the moves that make it up. Martin Fowler’s website refactoring.com, consulted on 12 November 2026, repeats the definition the author gives in his book “Refactoring”. The noun refers to a change made to the internal structure of software to make it easier to understand and cheaper to modify, without changing its observable behaviour. The verb refers to applying a series of such changes.
In French, usage employs “refactorisation” or “remaniement”. By observable behaviour, this entry means what a user or a calling program can see: results, messages, stored data.
Martin Fowler credits the technique with one effect: containing the cost of changes, which additions piled one on top of another make increasingly difficult. He says he restructures the code before adding a feature, so that the addition becomes simple, then after making it work, so that the code can be understood on rereading. It is one of the ways of paying down technical debt as you go.
A series of small verified transformations
The refactoring.com home page describes the heart of the technique: a series of small behaviour-preserving transformations. Each does little, and their sequence can produce a significant restructuring. The system remains in working order after each transformation, which reduces the risk of breaking it.
The website’s online catalogue names these transformations, including “Extract Function”, “Rename Variable” and “Move Function”.
Some development environments automate part of these moves. Martin Fowler considers them useful without regarding them as indispensable: failing that, he proceeds in small steps and tests frequently. When the code has no tests, characterisation tests, presented in our article on automated testing, first pin down the existing behaviour. Without a means of verification, preserving behaviour remains an intention.
Refactoring, rewriting, redesign, optimisation: not to be confused
Usage distinguishes these four operations by what changes and by what must remain identical.
| Operation | What changes | What remains identical |
|---|---|---|
| Refactoring | The internal structure of the code | Observable behaviour |
| Rewriting | The code, replaced by new code | The service provided, to be demonstrated afresh |
| Redesign | The functional scope, user journeys or architecture | What the project decides to keep |
| Optimisation | Response time or resource consumption | The functional result; readability may suffer |
Martin Fowler specifies that refactoring is not another word for cleaning up code: he reserves the term for this technique and uses “restructuring” as a more general term, for a reorganisation of the code that may use other techniques. Fixing a defect does not fall under it either, since it changes behaviour. As for a rewrite carried out in stages, it falls under a migration pattern, the strangler fig pattern.
The table also marks the limit of the practice. Understood in this way, refactoring changes neither the technical foundation nor the functional scope: a technology reaching end of support or a new need calls for other operations.
Example: an invoicing function nobody dares to touch
Consider an energy supplier’s invoicing application. A single function calculates consumption, applies the tariff, adds taxes and formats the invoice. A tariff option has to be added to it.
The team first writes tests that record the invoices produced for a set of contracts. It then extracts the consumption calculation into a named function, reruns the tests, then does the same for the tariff and for taxes. At each step, the invoices remain identical. The tariff option is then added in a short function, through a change separate from the previous ones.
Applied to an entire application estate, refactoring becomes one route among others, from encapsulation to replacement: our application modernisation page explains how to choose, and the safety net of tests it requires falls under software quality.