Refactoring• Improving the design of existing code (without changing its behavior)• Make a small change, run your tests.• Ifit takes more than a day, you’re rewriting, not refactoring.
legacy_code/README• “Legacy code” is code that doesn’t have tests.• It’s always easier to test new code than to bring legacy code under test.
Stay loose.• Loosely coupled objects are easier to test in isolation• Dependency injection, Strategy pattern• “awkward collaborators” (Feathers)
Is TDD worth it?
ZOMG RESEARCH• TDD teams took 15-35% longer• TDD teams created 40-90% fewer bugs “If we control for defect rate, is TDD faster?” http://grokcode.com/439/test-driven-development-and-the-meaning-of-done/