Overcoming Our Obsession with Stringly-Typed Ruby
summary
Argues that replacing ubiquitous strings with explicit data types prevents bugs: zip codes are five digits (about 100000 possibilities) so a ZipCode class that validates on construction stops invalid values from leaking. Shows Ruby techniques that work: SimpleDelegator wrappers, the to_str protocol, and ActiveRecord serialize to convert DB strings into objects. Builds a DB wrapper and ZipCode class that validate and convert, and demonstrates they prevent bad ZIPs from propagating.
AI-written summary · about
chapters (8)
- 0:00Start
- 7:18MUST BE A PROBLEM READING INPUT!
- 9:08THIS IS NOT HOW TO BUILD A MAINTAINABLE SYSTEM
- 10:18WHAT'S COMING AND WHAT'S GOING
- 12:34DATA TYPES
- 21:41SHOULD WE?
- 31:14ACTIVE RECORD
- 34:45ENUMERATED TYPES State/Province, Status Codes, Error Codes
related talks
34mThinking in Objects
30mRuby Techniques by Example
26mImmutable Ruby
37mChecking Your Types: An Overview of Ruby's Type System
01h 49mNo Static Types? No Problem!
30mDucks and monads: wonders of Ruby types
22mYou and your type[s] aren't welcome here
32mWhy We Can't Have Nice Things: Unicode, Dates, and Names
