Skip to content

Domain Modelling

alsi-lawr edited this page Jul 15, 2026 · 1 revision

Domain modelling

BlokeBot uses native C# record unions for finite domain states and outcomes with more than two meaningful cases.

Convention

  • Keep the union beside its owning domain rather than in a shared catalogue.
  • Use a public abstract record with a private constructor.
  • Represent cases as nested sealed records with get-only, case-local payloads.
  • Provide an abstract typed Match handler for every case.
  • Extend Match when adding a case so compiler errors identify every affected consumer.

Avoid

  • package or generator dependencies for the union;
  • Boolean discriminators;
  • enum-plus-null payload bags;
  • wildcard/default handlers;
  • fallback exceptions for declared cases.

The source note is docs/native-record-unions.md.

Clone this wiki locally