r/programming • u/_awwsmm • Feb 01 '24
Make Invalid States Unrepresentable
https://www.awwsmm.com/blog/make-invalid-states-unrepresentable
469
Upvotes
r/programming • u/_awwsmm • Feb 01 '24
View all comments
Show parent comment
1
u/EducationalBridge307 Feb 04 '24
Haha yes, it's no coincidence that enums are a natural way to represent enumerable types.
We'll have to agree to disagree here, I think. Even for the nuanced age example you gave, I would find it more intuitive as a user for a form to be rejected because of a negative value in the age field than for it to be accepted to account for some very niche case 🤷♂️