January 2018
Beginner to intermediate
312 pages
7h 22m
English
A composable type system is a great aid in doing domain-driven design because we can quickly create a complex model simply by mixing types together in different combinations. For example, say that we want to track payments for an e-commerce site. Let’s see how this might be sketched out in code during a design session.
First, we start with some wrappers for the primitive types, such as CheckNumber. These are the “simple types” we discussed above. Doing this gives them meaningful names and makes the rest of the domain easier to understand.
| | type CheckNumber = CheckNumber of int |
| | type CardNumber = CardNumber of string |
Next, we build up some low-level types. A CardType is an OR type—a choice ...
Read now
Unlock full access