tdd-refactoring

Installation
SKILL.md

Refactoring

Change the design, even radically, in small steps that keep every passing test green. In TDD a refactoring only has to preserve the tests you already have, for example turning a constant into a variable. That puts an obligation on you: write enough tests that "safe with respect to the tests" means "safe". "All tests pass" is no excuse when you know there's a problem. Write more tests.

Reconcile Differences

Problem: two similar pieces of code should become one. Answer: bring them closer step by step, and merge them only when they are identical.

  • This works at every scale. Make two loops identical, then merge them. Make two branches of a conditional identical, then drop the conditional. Do the same for two methods, or two classes.
  • Avoid leap-of-faith refactorings that rely on a long chain of reasoning. Take steps whose safety the tests can confirm.
  • Work backwards when useful: picture the trivial last step and head for it. For example, to remove subclasses, make each subclass's methods identical to the superclass's until the subclass is empty, then replace references to it with the superclass.

Isolate Change

Installs
1
First Seen
2 days ago