Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Modeling guidance: traits versus phases and categories

If it classifies, it is a concept; if it obligates behavior, it is a trait. “Adult” as a classification is an anti-rigid phase of Person — model it as pub type Adult <: Person iff { age >= 18 } and the substrate derives membership. Reach for a trait when otherwise-unrelated types must satisfy a common contract of derivations or operations (Closable, Auditable, per-jurisdiction rule families) — the contract is about what the types provide, not what their instances are. A trait carrying a single unary Self-member named like a classification is usually a phase in disguise.