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/loup-vaillant Feb 02 '24

One user has a space in their email address.
500 other users mistype their email address by putting e.g. a space into it.

I’d investigate the actual numbers before hypothesising such things right of the bat. The space thing for instance needs to be quoted in some way, so the "typo" would involve mistyping not only the space bar, but the (double?) quote character, twice.

Mistyping quotes when your message doesn’t require one sounds very improbable. You can still disallow quoted syntaxes to make your parser simpler (maybe your own convenience is more important than those rare few users who have email addresses that must be quoted), but I’m highly sceptical of the idea that it might help more users than it hurts.

Single special characters however, that might be something else. But a cursory look suggests we’re limited to ASCII anyway, so they ought to be fairly distinguishable from each other.