Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The enum is a bad abstraction because when I play GoFish, the computer asks, "Do you have any 13's?" and when I ask, "Do you have any Jacks?", I am always told to GoFish. It's an abstraction that sometimes returns a meaningful value, and other times doesn't, and the abstraction is built to optimize exactly the cases that are easy for me to reason about when writing a program and returns something that only looks correct in all the difficult cases, such as the Ace and so I wind up having to do all the heavy lifting myself anyway but only after having been misled to the wrong assumption that the abstraction was robust and well thought out.

There's no value to a warning that's irrelevant and perhaps even negative value if it encourages the idea of adding a wildcard last case just so I don't have it interrupting my thoughts each and every time I build my program since doing so opens the door to very run time errors it was supposed to prevent or conversely creates the habit of ignoring the compiler warnings in the very worst situation - when I think I know what I am doing.

If enums were good enough and I wanted to ignore compiler warnings, I could have used C.



> The enum is a bad abstraction because when I play GoFish, the computer asks, "Do you have any 13's?" and when I ask, "Do you have any Jacks?", I am always told to GoFish.

What? No it doesn't. Scala case objects don't have numerical values.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: