What It Actually Means
That definition contains the entire commercial problem with refactoring, which is that a successful refactor is invisible to you. You fund a fortnight of work and receive a product that looks and behaves precisely as it did before. There is no demo. There is nothing to show the board.
That makes it hard to judge, which is a different thing from wasteful.
Why You Are Hearing About It
Refactoring is proposed when the shape of the code has stopped matching the shape of the problem. That does happen. A system built to handle one type of customer, then stretched to handle four, ends up with the fourth type held on with tape. Every change to it is slow and risky, and the honest fix is to restructure rather than add a fifth layer of tape.
It is also proposed because developers find working in tidy code more pleasant than working in untidy code. That is a legitimate preference, but on its own it gives you no business case.
The distinction matters because both arrive in the same sentence: “we should refactor this first.”
Legitimate Or Not
Refactoring earns its cost when it is attached to something you were going to do anyway.
“We need to add multi-currency, and the pricing code assumes one currency in nine places, so we restructure that part first” is a strong case. The refactor is scoped by the feature, it has a boundary, and you can tell when it is finished because the feature ships.
“We should refactor the codebase before we do anything else” is a much weaker case, because it has no boundary and no completion test. Refactoring without a destination expands to fill whatever time it is given.
The size is the tell. Refactoring scoped to a feature is measured in days. Refactoring scoped to a codebase is measured in months, and is usually a rewrite that has been given a gentler name.
What To Ask
- What are we about to build that this makes possible or cheaper? If the answer is nothing specific, it can wait.
- How will we know it is done? A good answer names a feature that ships or a behaviour that stops happening.
- What is the risk of breaking something that currently works? This is the real cost of refactoring, and the answer should mention tests.
- Could we do this as part of the next feature rather than before it? Very often yes.
The Question That Settles It
One question separates careful refactoring from risky refactoring, and it is worth asking every time: what stops this from breaking something?
Restructuring code that has automated tests around it is a controlled activity. The tests confirm behaviour has not changed, which is precisely what a refactor promises. Restructuring code with no tests is not refactoring in any meaningful sense. It is rewriting and hoping, and the bugs surface weeks later in places nobody connects to the work.
If someone proposes a significant refactor and there are no tests, the first piece of work is writing the tests, because they are what makes the rest of it safe.
Refactoring is how technical debt gets paid down incrementally. It is not the right tool for an ageing platform, where the constraint is the technology itself rather than the structure of the code.
More terms are in the glossary.