Confident Code
summary
Argues that methods should have four ordered parts so they read like a story: input gathering, work, results, then failure handling. Demonstrates an interface to a Unix ASCII‑art cow utility and applies concrete techniques: to_s/to_a coercion, decorator or SimpleDelegator wrappers, guard clauses, Hash#fetch, and a null object via method_missing. Extracting checks into a bouncer method and small check wrappers removes midmethod digressions, lowers branch complexity, and makes the code easier to reason about and maintain.
AI-written summary · about
chapters (23)
- 0:00Intro
- 0:49What is confident code?
- 1:46Poor Storytelling
- 3:08Source Code
- 3:21Cowsay: ASCII art animals
- 4:19Timid Code Structure (Annotated)
- 4:46Narrative Method Structure
- 6:51Dealing with Uncertain Input
- 7:01When in doubt, coerce
- 11:15Encapsulating the Switch
- 11:54SimpleDelegator
- 14:43Assertion Method
- 14:53Ignore Unnacceptable Values
- 17:45Substitute Special Case for nil
- 18:54A Basic Null Object
- 21:00Use Hash#fetch when appropriate
- 21:53#fetch for defaults
- 22:33Symbol Default
- 24:03Confident Styles of Work
- 26:14Extract error handling methods
- 27:13Bouncer Method in Use
- 27:29Checked Method
- 28:37The Final Product








