5 ms·
> in mine, yes definitely 100% the second code is more readable than the first If anything, adding a nesting level for each chained predicate makes code harder
by simplotek 4y ago
> in mine, yes definitely 100% the second code is more readable than the first
If anything, adding a nesting level for each chained predicate makes code harder to read, and needlessly so.
- nuancebydefault 4y agoIt makes code a tiny bit more verbose but much more readible and most of all easily extendible without having to worry about bracket positions
- simplotek 4y ago> It makes code a tiny bit more verbose (...) The issue is not verbosity. It's the needless addition of nesting levels and independent expressions in a non-idiomatic way, which greatly increase the cognitive load of checking a single row of chained predicates. It's bad code.
- jcelerier 4y agofor me the cognitive load of if(an expression) { if(another expression) { } } is MUCH lower than if(an expression && another expression) { } which always raise the questions of: - did the author think about operator precedence - did the author want to use && or & - did the author think about short-circuiting (as evidenced in this very thread, a lot of people do not)
- nuancebydefault 4y agoAnd not to forget, is it okay to omit parentheses, does && take precedence over any other symbol in the expression?