A contextual attribute is meaningful only for a particular domain state. The attribute completedBy fits a Completed status, but distorts a generic Status when stored there. section 4.2.1
Use the attribute’s friction as feedback about the domain model:
- Combine attributes only when their meaning remains valid for every value of the containing type. section 4.2.1
- Move attributes that describe one state into a dedicated data type, such as Completed. section 4.2.1
- Separate other states, such as NotStarted and Skipped, instead of using generic fields that permit misleading combinations. section 4.2.1
Completed status
A generic Status containing instance, step, isCompleted, and completedBy mixes state meanings. A Completed record makes completedBy and completedOn belong explicitly to the completed state. section 4.2.1
Listing 4.27 Combining this attribute breaks the meaning of our data
record Status(
Instance instance,
/*AND*/ Step step,
/*AND*/ boolean isCompleted,
/*AND*/ User completedBy #A
){}Inspect the misleading generic Status record where completedBy is combined with a completion flag. section 4.2.1
