O'Reilly logo

Domain Modeling Made Functional by Scott Wlaschin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required