All glossary terms
Cross-cutting

Refactor

Refactoring is changing the internal structure of code without changing its external behaviour. The goal is to make code easier to understand, modify, or test — not to add features. Refactoring under test coverage is low-risk; refactoring without tests is rewriting in disguise.

Martin Fowler's 'Refactoring: Improving the Design of Existing Code' is the canonical reference. The discipline distinguishes refactors (behaviour-preserving) from rewrites (behaviour-changing). A real refactor passes the same tests before and after. The most common refactor anti-pattern: bundling a refactor with a feature change, then claiming any regression was 'just the refactor' — making both changes individually verifiable is the point.

Related terms