# Misleading Parentheses
Misleading parentheses [[anti-pattern]] refer to the excessive or unnecessary use of parentheses in code, particularly when they do not alter the natural order of operations. In many languages, arithmetic operators follow a clear order of precedence e.g. multiplication happens before addition.
Let's consider a simple example:
```python
10 + 5 * 25
```
Here, the order of operations is clear: is first performed the multiplication (`5 * 25`), then added `10`. The result is `135`. But what happens if we add unnecessary parentheses?
```python
10 + (5 * 25)
```
The result is still `135` because the parentheses do not change the already implicit order of operations. However, these parentheses are superfluous and misleading.
## Why is it a problem?
Parentheses are meant to change the order of operations. When they appear, the reader expects a change in that order. By adding parentheses when they are not necessary, we send a false signal: this forces readers to check if there is a special calculation they need to understand. It's like a false alarm: crying wolf too often makes developers less attentive to actual issues, potentially opening the door to subtle bugs.
## What is the best practice?
The golden rule is to trust the natural order of operations as long as it is clear. Use parentheses only when necessary to avoid ambiguity or to clarify particularly complex expressions.
Correct example:
```python
(10 + 5) * 25 # Here, the parentheses change the order of operations.
```
Misleading example:
```python
10 + (5 * 25) # These parentheses are unnecessary and confusing.
```
In conclusion, too many parentheses can confuse readers and reduce [[readability]]. Be cautious and use them only when necessary to change the order of operations or improve clarity.