Refactoring Live: Primitive Obsession
summary
Live refactoring of a Rails app untangles Primitive Obsession by replacing string grades with a Grade value object, adding a Grade.for factory to accept either strings or objects, implementing Comparable via the spaceship operator to compare scores, and moving score logic off Transcript into Grade. ActiveRecord fields serialize to Grade with ActiveRecord serialize methods, tests run with guard + RSpec, specs stay green and adding plus/minus grades and an assistant role becomes two-line changes.
AI-written summary · about
chapters (15)
- 0:00Intro
- 0:37What is refactoring
- 2:07How to refactor
- 5:49Demo
- 11:38Adding a grade class
- 13:38Converting values to objects
- 15:43Updating calls to new
- 18:15Grades
- 21:08Converting Strings to Grades
- 23:49Changing the Contract of Grade
- 25:21Making Improvements to Grades
- 27:08Comparing Grades
- 29:28Updating Grades
- 30:14Updating Roles
- 36:30Conclusion
related talks
48mRefactoring from Good to Great - A Live-Coding Odyssey
44mRefactoring from Good to Great
47mRefactoring from Good to Great
33mSo You Want to Start Refactoring?
25mRefactoring: The ASMR of Programming Talks
28mFluent Refactoring
40mWorkshop - Simplifying Code: Monster to Elegant in Less Than 5 steps
31mAn Optimistic Proposal for Making Horrible Code... Bearable
