Write Small Things
summary
Builds a real Ruby command-line option library from zero to working tests and shows the refactor steps that get it maintainable: starts with an instance_eval DSL over ARGV, adds string/integer/boolean/array options, extracts behavior with extract method and extract class, replaces a case switch by constantizing types to remove hard dependencies, and injects abstractions so option objects handle parsing and validation. Specs drive changes; examples end green and the library handles values, validation, and delegation without tangled dependencies.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 1:31Small clean code matters
- 2:32Small code as design
- 4:18Dependency management challenge
- 5:21Tools for small code
- 6:23Rules for small methods
- 9:18Command line option library
- 14:04Refactoring to remove duplication
- 16:37Handling new requirements
- 18:30Extracting polymorphic behavior
- 19:55Small classes with single responsibility
- 21:21Extracting StringOptions class
- 23:06Creating parent Option class
- 23:48Breaking dependencies with DI
- 25:37Separating abstractions from implementations
- 27:44Adding array options support
- 28:06Conclusion & Q&A
related talks
35mWriting Small Code
42mUsing Ruby to Craft and Test Beautiful Command Line Applications
43mBuilding a Ruby Library the Parts No One Talks About
50mWriting Solid Ruby Code
44mRuby Libraries Important for Rails
32mruby best practice patterns
29mCommand-Line Applications in Ruby: Design Patterns and Best...
06mRuby on the Command Line
