Flexible Modeling: Keeping Your Domain Pure with Scala 3
summary
Refactors a boilerplate-heavy user domain by replacing wrapper classes and implicits with opaque types, extension methods, enums and union types. Shows a concrete airline example: add name.toAirlineSafe via an extension method instead of wrappers; use opaque types to make Name distinct from UserId with 100% no runtime allocation but explicit smart constructors; replace sealed-trait boilerplate with three-line enums; use union types to model search results without leaking a common trait. Result is a minimal, boundary-clean domain that compiles and runs.
AI-written summary · about
chapters (7)
- 0:00Clean domain modeling
- 3:11Integration leaks with extensions
- 10:00Replacing AnyVal with opaque types
- 15:37Simplifying enums for status
- 17:23Preventing API leaks with union types
- 20:57Clean domain matters with AI
- 23:10Summary of Scala 3 tools
related talks
39mA few tips on modelling things in Scala
30mLessons Learned from 15 Years of Scala in the Wild
38mThinking Less with Scala
32mAdvanced Features of Scala 3
51mOpening Keynote: New Functional Constructs in Scala 3
01h 02mPrinciples and tools to cleverly model your data in Scala
38mThinking in Scala 3 Types
49mTen Cool Things You Can Do With Scala 3
