Software Engineering · Cluster
Refactoring
Behavior-preserving change at scale.
- 01 The Equivalence Relation That Refactoring Depends On Refactoring is defined as behavior-preserving change, which first requires deciding what counts as behavior. That decision is the whole discipline.
- 02 Extract Function and the Preconditions the Compiler Checks Extraction is presented as a mechanical edit, but it is only safe when the extracted body captures no free variables, no control flow, and no implicit receiver.
- 03 Why Textual Renaming Fails and Syntax Trees Do Not A search-and-replace rename breaks on shadowed names, comments, string literals, and macro bodies. A rename that walks a syntax tree knows which occurrences bind.
- 04 Characterization Tests as a Refactoring Safety Net When code has no specification, the only available oracle is the code itself. Recording current behavior turns a rewrite into a comparison against captured output.
- 05 Seams: The Places Where Behavior Can Be Substituted A seam is a point where an edit can change behavior without editing at that point. Link seams, object seams, and preprocessor seams cost different amounts and fail differently.
- 06 Branch by Abstraction and the Cost of Two Live Paths Replacing a widely used component without a long-lived branch means running both implementations behind one interface. The interface, not the code, is what has to be designed.
- 07 Expand, Migrate, Contract: Changing an Interface Without a Flag Day When callers cannot be changed in one deploy, the change is split into three phases that are each independently safe: add the new shape, move every user, remove the old.
- 08 Repository-Scale Codemods and the Review Problem A codemod that rewrites ten thousand call sites produces a diff nobody can read. Sharding, mechanization proofs, and a declarative matcher are what make the change reviewable.
- 09 Migrating Stored Data While Both Formats Are Live A dual-write phase lets code change before data does, but it trades a clean cutover for a consistency problem. Ordering, backfill, and verification decide whether it holds.
- 10 What Behavior-Preserving Change Cannot Preserve Cost, stack shape, interleaving, and resource lifetime fall outside the observation set by design. The cases where that exclusion stops being acceptable are the ones that matter.