3 ms·
I see your point, but I'd argue that even then it's still the wrong the problem. 1. If you don't enjoy maintaining your switch statement, it's probably huge an
by jmts 10y ago
I see your point, but I'd argue that even then it's still the wrong the problem.
1. If you don't enjoy maintaining your switch statement, it's probably huge anyway and you need to refactor.
2. If you don't enjoy maintaining this switch statement, you probably also don't enjoy maintaining the switch statement inside next function that gets called that gives you your full set of valid values.
3. The number of types of messages used is probably much fewer than unique messages, so you are optimising on a small N, which will give minimal returns.
4. You never need to look at this code again and it will just sit there adding overhead. Other switch statements will be maintained because they're the first place you'll notice missing entries.
Fun, sure. Like setting a fistful of matches on fire. It takes a bit of effort to set up, and it looks interesting. I'll agree to that.