3 ms·
I once (briefly) tried to collaborate with someone who would not use `else if` statements, and used braces always even if they were optional. if (foo) {
by TheLoneWolfling 11y ago
I once (briefly) tried to collaborate with someone who would not use `else if` statements, and used braces always even if they were optional.
if (foo) {
<whatever>
} else {
if (bar) {
<whatever>
} else {
if (baz) {
<whatever>
} else {
if (spam) {
<whatever>
} else {
...
<etc>
}
}
}
}
It didn't end well.
He also wouldn't use break or continue or multiple returns.
As this article says, it led to really really annoying-to-read code.
- agumonkey 11y agoPardon me lisping, but I just read your code as pseudo linearization of trees... (cons a (cons b (cons c (cons d . nil)))) (list a b c d) a,... being condition/reaction pairs.
- TheLoneWolfling 11y agoEffectively. It's one of the reasons why I wish more languages had a generalized switch statement (i.e. one that accepted arbitrary code as conditions, not just constants compared to a single value), preferably with a way to (explicitly, preferably) code a fall-through. It means that you cannot necessarily translate it into a jump table, true. But it means that you can write code much more concisely, on the flip side. And it remains slightly readable.