Domain modeling
Modeling a domain so that the types say which values can exist and which transitions are legal, following Wlaschin’s Domain Modeling Made Functional. Part of Type-driven design.
- Domain modeling with types: overview of the folder, type-first design, how the vocabulary translates across languages, values, entities and aggregates, and errors as values.
- Newtypes and simple values: primitive obsession, newtypes, value classes and opaque types, and constrained simple values.
- Algebraic data types: product and sum types, counting values as a design check, and sum types versus tagged classes and class hierarchies.
- Making illegal states unrepresentable: business rules as choice types, connascence of value, booleans, a flag plus an optional value, and behaviour as data.
- Workflows and states: workflows as function types, one type per state, state machines, typestate with phantom types, and long-running workflows.