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

  1. Pin It Down: Tests for Code You Didn't Write (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 (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.