Should I use parentheses in logical statements even where not necessary?
- by Jeff Bridgman
Let's say I have a boolean condition a AND b OR c AND d and I'm using a language where AND has a higher order of operation precedent than OR. I could write this line of code:
If (a AND b) OR (c AND d) Then ...
But really, that's equivalent to:
If a AND b OR c AND d Then ...
Are there any arguments in for or against including the extraneous parentheses? Does practical experience suggest that it is worth including them for readability? Or is it a sign that a developer needs to really sit down and become confident in the basics of their language?