News for hackers. Stuff that matters.
Re:'Make invalid states unrepresentable' considered harmful by lock1 on Monday September 08, 2025 @01:54AM (#45165008)
+1

In cases like electronics & protocols, it's very often a good idea to add an extra "reserved & unused" section for compatibility reasons.

These representations need not be 1:1 with the domain model. Different versions of the model might reject previously accepted representation in case of breaking changes. It's up to the dev to decide on which conflict reconciliation strategy they should take (fallback values, reject, compute value, etc).

Working with a precise domain model (as in, no representable invalid states) is way more pleasant than stringly-typed/primitives mess. We can just focus on domain logic without continuously second-guessing whether a string contains valid user.role values or it contains "cat".

There are no comments on this comment yet.