Refactoring changes a program’s internal structure without changing its externally observable behavior. It can make code easier to read and change, but cleaner structure alone does not guarantee good production behavior. section 10.2 section 1.1.3
Common code-level refactorings include:
- Rename a variable for clarity or extract a method to reduce duplication. section 10.2
- Replace a conditional with polymorphism or move a function to a more appropriate module. section 10.2
Before changing legacy code, understand its business rules and invariants. A technical-looking condition may encode a real constraint; changing it without understanding can break behavior. Existing tests may also miss performance, operational, or architectural assumptions, so validate those constraints early. section 7.1 section 1.1.3
A code change or a process change?
Extracting a class to improve cohesion is refactoring because it improves code structure. Adding a CI cache to reduce build time changes the delivery process instead. The target—not whether code was edited—distinguishes refactoring from Kaizen. section 10.2




























