3 ms·
It always depends on the language that you are using. In c#, for simple cases, enums are perfect, but otherwise you should switch to classes hierarchies. In Jav
by tigershark 8y ago
It always depends on the language that you are using.
In c#, for simple cases, enums are perfect, but otherwise you should switch to classes hierarchies.
In Java you can use them in more complex cases because you can encode data quite easily.
If the amount of data encoded is becoming too much (let’s say more than a couple/three fields per case) than you should switch to classes.
In F# you can use a combination of sum and product types and have a happy life with automatic deconstruction and a somehow less happy one with lenses/optics.