3 ms·
> As long as these states are mutually exclusive, it's far more elegant to add another enum value rather than new fields. In my experience these states are oft
by cle 5y ago
> As long as these states are mutually exclusive, it's far more elegant to add another enum value rather than new fields.
In my experience these states are often not mutually exclusive. Boolean encoding is a superset of enum encoding.
Additionally, enums in many programming languages are often over-strict and easy to use in a non-forwards-compatible way.
Any advice that starts with "never" or "always" is suspect advice IMO. Study your domain, and decide whether you want to lock yourself into a mutually-exclusive state space and deal with consumers who may consume it in a way that prevents adding new states. Sometimes enums make sense, sometimes they don't.