Comparison
Always-valid domain modelvsSchema-on-write
Always-valid domain model
you could not construct an invalid one, so nothing downstream had to check whether it was valid.
The stance that an object should enforce its invariants at construction and at every mutation, so an instance in a bad state cannot exist. It removes defensive checking everywhere downstream and makes an invalid state a construction-time error rather than a runtime discovery. The usual objection is form validation, where you need to collect several errors at once rather than fail on the first — which is an argument for validating input separately, not for letting the model be invalid.
Full entry →Schema-on-write
the load rejected the file because a column changed type, and the bad data never got into the table.
Validating and typing data as it is written, so everything in the table conforms. The rejection is the feature: a failed load is a loud, single, fixable event, while a silently accepted bad type is a quiet wrong number spread across every downstream consumer. The complaint against it is always speed of onboarding, which is exactly the cost it is charging on purpose.
Full entry →