4 ms·
I tried several times to refactor a 10k+ line switch statement which had a particular case that by all logic should be unreachable, but had a comment something
by justizin 11y ago
I tried several times to refactor a 10k+ line switch statement which had a particular case that by all logic should be unreachable, but had a comment something like this:
/* I don't know why, but if you remove this everything breaks */
I wonder if that is still there, it's been over ten years.
- tunesmith 11y agoI got bit by something like that last year - a previous case above it had some logic without a break. I removed a case that switched on a class that no longer existed, but had a break. It was effectively stopping the fallthrough from the case that was a couple of screens above. Stuff broke, and I cursed the no-longer-employed developer that felt the need to be clever two years previous. Java and PHP allow cases that have logic and no break/return, and it's (strongly) arguable that it's a bug. I think C# doesn't allow that. It allows fall-through, but only if the case is empty.
- to3m 11y agoIn C# you can use `goto' to go to any other case as required - including the one that's next, syntactically speaking. So if you need a fall-through from a non-empty case, you can do that, but you do have to be explicit about it.
- acveilleux 11y agoAnd when you take out the case that is "not needed anymore" the compiler will yell at you. I like it.
- gohrt 11y agoDid you test the claim in the comment?
- Nadya 11y agoThat single comment sums up most everything that holds up the internet. And because I absolutely love this article, somewhat related: http://www.stilldrinking.org/programming-sucks http://www.stilldrinking.org/programming-sucks
- bpicolo 11y agoSounds like it's time to log things.