News for hackers. Stuff that matters.
Re:How Enums Spread Disease – And How to Cure It (2012) by peeters on Wednesday April 15, 2015 @05:55PM (#9384459)
The main point of an enumerated type is that it should be closed. You control all instances of the type, so that you and the compiler can benefit from the fact that it's closed.

If the fact that enums are closed ever presents a problem, then it's a good indication that you shouldn't be using enums. That's not a problem with enums, it's just a bad design decision that needs to be reversed.

Agreed that Vehicle is a poor choice for an enum, because it's something that isn't really closed. But if you're modelling something like states of a TCP connection, there's nothing dangerous about it being closed.

There are no comments on this comment yet.