2 ms·
Looking at the code in the examples, the first style thing that I would suggest fixing is that the name of a boolean variable should be a yes/no question which
by btilly 8y ago
Looking at the code in the examples, the first style thing that I would suggest fixing is that the name of a boolean variable should be a yes/no question which the value is an answer to. So don't name the boolean "temporary". Name it "isTemporary" instead.
Moving on to the actual point, for a balanced view just look at cyclotomic complexity. In a function, count the decision points. Every if and loop counts. Any function with 10+ decision points is too complex and needs to be refactored to make the control flow more obvious.
Following this rule will let you use if quite happily, while also avoiding the problems with it.
(A side tip. If your language has some variant of "unless", don't use it. Ever. Our brains do not do de Morgan's laws naturally. So you can write code that is clearer upon writing, but is much harder to keep straight when you're debugging. The time that you need to understand your code best is while debugging, so ease of debugging is more important.)