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 feasable 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.
- Designing with types: Introduction. Making design more transparent and improving correctness.
- Designing with types: Single case union types. Adding meaning to primitive types.
- Designing with types: Making illegal states unrepresentable. Encoding business logic in types.
- Designing with types: Discovering new concepts. Gaining deeper insight into the domain.
- Designing with types: Making state explicit. Using state machines to ensure correctness.
- Designing with types: Constrained strings. Adding more semantic information to a primitive type.
- Designing with types: Non-string types. Working with integers and dates safely.
- Designing with types: Conclusion. A before and after comparison.