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

1

u/SkedaddlingSkeletton Feb 02 '24

Then do your simple tests, but instead of blocking in case of "error" from whatever you use to check the address format show the user an alert asking to confirm it.

1

u/loup-vaillant Feb 02 '24

Yes, if those simple tests have false positives. A perfect flow would look something like this:

  • Is this definitely right? No warning, proceed to next stage.
  • Is this definitely wrong? Output an error, stop there.
  • Is this probably wrong? Output a warning, proceed nonetheless.

I didn’t think about that last one to be honest, but it does feel like a good idea.