Small Code
summary
A 31-line command‑line options class with one bulky value method and duplicated argv parsing gets refactored into small option classes (boolean, string, integer, later array) using extract method and extract class plus move method and dependency inversion. The top-level class ends with two public methods, valid and value, no conditionals, and tests moved from the monolith to per-option specs; adding a new type needs only a new option class and a red→green spec to make it work.
AI-written summary · about
chapters (10)
- 0:00Introduction
- 1:44Defining small code
- 9:07Command line parser example
- 13:21Good method principles
- 18:58Handling integers
- 22:06Small cohesive classes
- 25:39Dependency inversion
- 28:53Extracting option classes
- 30:37Final refactored class
- 32:45Testing new options
related talks
35mWriting Small Code
42mObject reorientation
55mAll TheLittle Things
27mClean Code: Applying Object Oriented Principles
27mUseful Functional-Options Tricks for Better Libraries
01h 05mAbstraction Patterns: Making Code Reliably Better Without Deep Understanding
29mBuilding Nice Command Line Interfaces — A Look Beyond the stdlib
35mFive Lines of Codes
