All lessons in Software Engineering: Programs, Systems, and Maintainable Software

Debugging, Characterization, and Refactoring

Reduce a failure, test a causal hypothesis, and change structure without changing the contract.

40 minutes · Members lesson · preview

What you will learn

  • Reduce a reported failure to a reproducible counterexample.
  • Distinguish a causal test from an observation that merely correlates with failure.
  • Refactor behind characterization tests while preserving the stated contract.

A user reports that the active-loan count becomes too large after a title receives another category tag. The defect appears in a report, but the cause may be a join multiplying rows. Debugging starts by narrowing the disagreement between expected and observed behavior, not by rewriting whichever function looks untidy.

A disciplined investigation produces a reproduction, a causal explanation, a minimal repair, and a regression test. Refactoring is a related but different activity: it changes structure while preserving behavior under the chosen contract.

Choose another lesson