In this series, we’ll look at some of the ways we can use types as part of the design process. In particular, the thoughtful use of types can make a design more transparent and improve correctness at the same time.
This series will be focused on the “micro level” of design. That is, working at the lowest level of individual types and functions. Higher level design approaches, and the associated decisions about using functional or object-oriented style, will be discussed in another series.
Many of the suggestions are also feasible in C# or Java, but the lightweight nature of F# types means that it is much more likely that we will do this kind of refactoring.
1. Designing with types: Introduction
Making design more transparent and improving correctness
2. Designing with types: Single case union types
Adding meaning to primitive types
3. Designing with types: Making illegal states unrepresentable
Encoding business logic in types
4. Designing with types: Discovering new concepts
Gaining deeper insight into the domain
5. Designing with types: Making state explicit
Using state machines to ensure correctness
6. Designing with types: Constrained strings
Adding more semantic information to a primitive type
7. Designing with types: Non-string types
Working with integers and dates safely
8. Designing with types: Conclusion
A before and after comparison