I've heard people argue "parentheses make code more readable" or "parentheses make code less ambiguous". Parentheses neither help nor hinder ambiguity or readability, your style decisions beyond use of ()
do that.
Here's a bug we introduced in our application that was allowed through by a coding style that preferred parentheses. If you follow a coding style that omits all unneccesary parentheses (only those that suppress warnings, which I prefer) this bug would have been impossible.
The bug is simple but subtle. The environment-specific data wasn't fetched from config/two.yml
because a )
was in the wrong place. Neither my coworker who wrote it, another coworker who reviewed it, nor my own review of the line caught it.
Without parentheses, though, there is no way to introduce this class of bugs because you can't chain off of intermediate results without introducing a local variable.
The main difference between the two examples is not the use of parentheses, it's the style in which the code is wri