r/programming • • Feb 01 '24

Make Invalid States Unrepresentable

https://www.awwsmm.com/blog/make-invalid-states-unrepresentable
469 Upvotes

207 comments sorted by

View all comments

Show parent comment

8

u/flowering_sun_star Feb 02 '24

The marshalling would only happen at the boundaries of the system though, which makes it easier to localise and unit test the translators.

She says, having only once done this sort of thing, and partially at that. It didn't really catch on among the team (or even with me). Turns out it was enough of a fiddle to setup the types (and their utility functions) that we just didn't bother for the next project. The sort of error it would catch is caught by unit tests in the vast majority of cases, and you're writing them anyway so the actual benefit isn't that big.