State Machines
In the section above, we converted a single type with flags into a set of separate types, each designed for a specific workflow stage.
This is the second time we’ve done this. In the EmailAddress example discussed, we converted a design with a flag into a design with two choices, one for each state: “Unverified” and “Verified.”
These kinds of situations are extremely common in business modeling scenarios, so let’s pause and look at using “states” as a general domain modeling tool. In a typical model, a document or record can be in one or more states, with paths from one state to another (“transitions”) triggered by commands of some kind as shown in the figure. This is known as a state machine.
Now you might be familiar with complex ...
Get Domain Modeling Made Functional now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.