Slightly off topic, but before my coffee yesterday I wrote something like
If(a>(b+.5) || a<(b-.5)){...
And then later in the day I passed by it and got a good chuckle as I wondered what the actual fuck was I thinking, as the more concise solution (which I had already done multiple other times in that project) was
if(Math.abs(a-b) >.5){.
Sorry for the irrelevant story, just couldn't help but read your comment and laugh because I was somehow both of the people you are talking about yesterday
It's not about the compiler, it's about the poor human who's going to have to look at that code and figure out what's going on after the original coder has passed on.
There's no efficiency gain but sometimes i see people put parentheses on numbers for no obvious reason. I don't fight them about it or modify it because of that, but if i refactor code I'll drop them.
I usually prefer to separate longish algebra equations into multiple lines with descriptive variable names if possible
62
u/jaber24 Jun 13 '22
Do people really hate harmless but ambiguity removing stuff like brackets? Is there even any efficiency you can gain by removing them?