2 ms·
I'm a massive fan of using parentheses even when not strictly necessary. I find it helps me visually parse the code better then a long chain of boolean expressi
by secondcoming 4y ago
I'm a massive fan of using parentheses even when not strictly necessary.
I find it helps me visually parse the code better then a long chain of boolean expressions. I don't bother with it when a term in the expression is simple, e.g
if (b1 && (b2 != b3))
rather than
if ((b1) && (b1 != b3))
- mike_hock 4y agoI think the discussion is silly. 99.9% when the condition is "too hard to read" it's because the condition is too hard to read, period, and the correct fix is to restructure the code to have readable branch conditions, not to throw parentheses on there to make a monster expression slightly less confusing. It's like discussing the chemistry of air fresheners instead of taking the trash out more often.
- wruza 4y agoDo you think that any other fix that makes it readable is incorrect?
- usrusr 4y agoI'm in the opposite camp: more names means more identifiers to keep track of while reading in case they might be referenced more than once, even if it's just a short but nonetheless distracting check "ok, that's where the scope ends". There are certainly times when I take the name approach nonetheless, but more like a last resort, or when I expect full contact stepthrough with a debugger. If I deem it likely that I will get by with merely brackets and copious amounts of whitespace, that's what I'll do.
- throwbadubadu 4y agoLol no, since when is a simple expression of four operands "(a someoo b) && (c someop d)" a too hard to read condition, I could only accept at least 5 .. at least ;)