# Before You Change It

Before You Change It: Pin It Down: Tests for Code You Didn't Write, Refactoring Toward a Pattern, One Small Step at a Time.

Updated: November 17, 2026

1. [Pin It Down: Tests for Code You Didn't Write](https://www.ask-codey.com/lessons/dp-characterization-tests) (Journeyman): Before changing old code that has no tests, write tests that record what it does today, right or wrong, so any change that alters its behavior shows up at once; these characterization tests pin the code down, surprises included, and the surprises become questions for the people who know the business.
2. [Refactoring Toward a Pattern, One Small Step at a Time](https://www.ask-codey.com/lessons/dp-refactoring-toward-a-pattern) (Journeyman): With old code pinned down by tests, you can reshape it toward a pattern in steps so small that each one keeps every test green, running the tests after every step and undoing any step that turns one red; the gym's plan if chain becomes a dictionary of pricing rules, and a new family plan becomes one line.

Source: https://www.ask-codey.com/courses/design-patterns/topics/dp-before-you-change-it
