4 ms·
> "all enums and integer IDs start at 1" then whoever takes over maintenance from you and wants to make improvements says "hey, we can add this new v2 feature
by fsckboy 4y ago
> "all enums and integer IDs start at 1"
then whoever takes over maintenance from you and wants to make improvements says "hey, we can add this new v2 feature through the 0x0 which is available for future enhancements"
- klodolph 4y agoUnlikely. The way it works is you define your enums like this: enum class Color { Invalid, // Not a valid value. Red, Orange, Yellow, Green, }; I think if someone's crazy enough to reclaim a 0 value in an enum or integer ID, then they're probably going to do a lot of damage to the code no matter what you do.
- benreesman 4y agoYeah, pretty much every integer enum I write has `UNKNOWN` or `INVALID` as the zero value. It adds either a `case` or a `default` to every switch and a clause or a `_` to every `match`, but it saves my ass even in non-security-sensitive settings.