Weird title, no? I couldn’t think of a snappier one, I’m afraid.
I’ve been thinking of a way to ensure that this sort of subtle bug/typo doesn’t happen:
This bug would be hard to find because there’s no compile-time error, and you wouldn’t necessarily even get an exception at run-time. You’d just get "unexpected results".
To resolve this in a simple way, I’ve experimented with using empty enum definitions. Effectively making a user id a data type (without going quite as far as a class or a struct):
What d’you think?