Refactor without changing behavior Understand the idea Refactor without changing behavior. Refactoring changes structure while preserving intended behavior. A migration changes a dependency, interface, or data representation and needs compatibility planning. See a concrete example See a concrete example. Choose one duplicated formatting function. Write examples of its current inputs and outputs, consolidate it, then run the same examples and callers’ tests. Try it yourself Pause the video and complete the exercise. Avoid this mistake Avoid this mistake. Combining a broad rewrite with a feature change. Split them into reviewable stages. Check your result Check your result. Behavioral examples still pass and callers have not changed their contract. Open the lesson below, try the exercise, and mark it complete only after checking the result.