4 ms·
This might have been valid in 00's Java/C#. However, most modern languages and even Java 16+ have good Enum support and exhaustiveness checks, making them very
by dtech 5y ago
This might have been valid in 00's Java/C#. However, most modern languages and even Java 16+ have good Enum support and exhaustiveness checks, making them very convenient and safe to express a limited set of possible values.
In contrast, an alternative like polymorphism + a visitor is safe, but excruciatingly verbose and hard to follow and modify.