Code Smell 19 - Optional Arguments
24 October, 2022
7
7
2
Contributors
TL;DR: Optional Arguments generate a hidden coupling in the name of smaller code.
Problems
•
Coupling
•
Unexpected results
•
Side effects
•
Ripple Effect
•
In languages with optional arguments but limited to basic types, we need to set a flag and add an accidental IF (another smell).
Solutions
1.
2.
3.
Sample Code
Wrong
Right
Detection
Tags
•
Optional
•
Laziness
Conclusion
More info
The trouble with programmers is that you can never tell what a programmer is doing until it’s too late.