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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access