by mailslot · 7y ago · 0 comments
For example: Countless engineers I’ve worked with don’t know operator precedence. So tons of ”y = ((i * m) + b);” type stuff. Do not need any parentheses in this case, but if I remove them, then they have no idea what happens... So they litter all math with superstitious parens.
There are so many better examples, but you get the idea. I have suffered “coding standards“ that existed solely because of the devs that won’t RTFM.
For readability, yes... sometimes, but for readability sake, not “I don’t know what this does without them.”
I’m not just talking about math operators, but logical ones too. I’ve seen people put parens around every “not” because they weren’t sure. There are three essential logical operators. Surely those can be learned at least. And yes... in those cases where readability is an issue, of if they’re necessary, please do add them, but please don’t if you’re unsure what “!a && b || c” does. Seeing “((!a) && b) || c” raises red flags.
They communicate to people who don't know the binding, but perhaps more importantly they don't let you accidentally change order of operations if you change the operators in your computation.