Down The Rabbit Hole: An Adventure in Legacy Code
summary
Adds concrete steps for changing legacy Rails code: write tests to preserve behavior, use Rails model specs (joins and queries) to reproduce and fix a silk-blend bug, implement minimal query changes to make tests pass, then run the full suite before refactoring. Uses a contrived Yarn Hearts marketplace example and a real-world get_sellers method with nested conditionals, demonstrates that incremental tests + fixes work and suggests extracting classes or polymorphism when time allows.
AI-written summary Β· about
chapters (18)
- 0:00Introduction
- 1:20What is Legacy Code
- 4:37When not to change
- 5:36Four reasons to change
- 6:58Adding a feature
- 7:53Testing
- 9:57Why Test
- 13:23Yarn Model
- 15:04Get Sellers
- 17:00Write the simplest test
- 18:51Add tests
- 20:44Refactoring
- 22:49Test
- 29:38Look for opportunities
- 31:13Example
- 32:28Changing the code
- 35:22Lessons learned
- 37:12Recommendations
related talks
28mHarry Potter and the Legacy Codebase
23mLoving Legacy Code
36mUsing Tests as a Tool to Wrangle Legacy Projects
34mTesting legacy code when you dislike tests (and legacy code)
31mIf it bleeds, it leads
40mInto the Heart of Darkness: Rails Anti-Patterns
36mWorking Compassionately with Legacy Code
34mCode Spelunking: teach yourself how Rails works
