Refactoring for Rails - using deodorant to prevent code smells
summary
Advocates running RuboCop before committing and using extract method plugin for Vim or Sublime to make refactors practical, plus lint-staged for JS. Requires green tests before any refactor; missing an else in a case once lets new enum values explode after six months. Calls out a copied User class across five apps, whale classes of 500–1,000 lines, and controller actions of 50–100 lines as concrete smells. Recommends separate refactor PRs, extract superclass/modules, value objects or Structs, and never put modules in migrations.
AI-written summary · about
chapters (12)
- 0:00Refactoring and code smells
- 3:15Code smells and risks
- 7:14Sustainable refactoring rules
- 10:34Spaghetti code fixes
- 13:10Whale classes and dosing methods
- 15:43Complex classes simplified
- 17:08Unnecessary code and comments
- 20:25Code dependency risks
- 22:12Fat controllers and thin models
- 24:02Rails migrations and views best practices
- 26:09Automated refactoring with RoboCop
- 27:37Summary
related talks
33mSo You Want to Start Refactoring?
23mKeeping Code Style Sanity in a 13-year-old Codebase
33mRefactoring Towards Component-based Rails Architectures
28mRESCUE SQUAD: Rails Edition!
40mInto the Heart of Darkness: Rails Anti-Patterns
34m"Taming your Rails monolith"
40mWorkshop - Simplifying Code: Monster to Elegant in Less Than 5 steps
20mWhat were they thinking?
