Modeling Each Step in the Workflow with Types
The state machine approach is perfect for modeling our order-placing workflow, so with that in hand, let’s now model the details of each step.
The Validation Step
Let’s start with validation. In the earlier discussion, we documented the “ValidateOrder” substep like this:
| substep "ValidateOrder" = |
| input: UnvalidatedOrder |
| output: ValidatedOrder OR ValidationError |
| dependencies: CheckProductCodeExists, CheckAddressExists |
We’ll assume that we’ve defined the input and output types (UnvalidatedOrder and ValidatedOrder) in the same way as in the discussion earlier. In addition to the input, we can see that the substep has two dependencies, one to check that a product code exists and one to check that ...
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.