Chapter 6: Ruling out invalid states with types (optional advanced reading)

In this chapter

  • 6.1 When a single record becomes insufficient
  • 6.2 Modeling the lifecycle with unions and state types
    • Make each method’s input and output states explicit
    • Types do not replace all validation
  • 6.3 Pattern matching on unions
    • Union or closed hierarchy?
    • Modeling states with record inheritance in C# 14
  • 6.4 The costs of union state models
    • More types and mappings
    • New operations and new states have different costs
    • Framework integration still needs separate models
  • 6.5 When it is worthwhile
  • 6.6 Migrate gradually
  • 6.7 Chapter review

This chapter is not available in the free preview. Purchase the book to read the complete edition now.

Buy this book