Design for errors — an introduction to Domain modelling with a bit of Arrow
summary
Walks a real API from nullable JSON DTOs to strict domain types in Kotlin using the Arrow library, replacing nullable strings with smart constructors, a sealed VerifiableEmail type and a NonEmptyList for contacts so invalid states can’t be represented. Wraps an unsafe sendEmail into an effectful call returning Option/Either/Try so network errors, timeouts or verification failures are explicit. Shows how these types stopped accidental defaults (anonymized 7‑Eleven incident) and how validation and composition actually work in practice.
AI-written summary · about
chapters (12)
- 0:00Introduction and motivation
- 1:52Primitive obsession in domain modeling
- 7:13Smart constructors and validation
- 13:20Introducing Option type for errors
- 21:54Email validation and domain types
- 25:53Verified vs unverified email states
- 33:48Handling missing data and defaults
- 41:04Refactoring user profile with ContactInfo
- 45:00Non-empty lists for business rules
- 47:11Try type for exception handling
- 51:46Key principles of domain modeling
- 53:57Q&A session
