4 ms·
So you propose a) Having a "boolean" enum which does't solve the problem or having dozens of unique "boolean" enums which is a maintenance nightmare. Instead, I
by 67726e 12y ago
So you propose a) Having a "boolean" enum which does't solve the problem or having dozens of unique "boolean" enums which is a maintenance nightmare. Instead, I can use my IDE to tell me the names and ordering of parameters, and a type checker to verify everything at compilation. You'll never completely stop the problem of logical errors, and enums are certainly no panacae.
- cousin_it 12y agoI think in languages like ML or Haskell, people are encouraged to be trigger-happy about creating enums with meaningful names for every tiny use case. That's a viable approach because defining a new enum literally takes one line, and working with enums is very natural due to pattern matching. The maintenance nightmare doesn't seem to happen. Though in languages like Java that approach would be much less convenient.
- 67726e 12y agoI can understand that line of thinking, but in given the OP is talking in JS, and and that I've only ever written such languages at Uni or for practice, I don't find them applicable to my day to day. I deal with Java, Scala, JS, and a few other C-style languages. These are how I think and work, these are, and I'm going to assume (make an ass of you and me ;)) that these are what the majority of HNers deal in.