Disguised as a friendly shortcut is another coupling smell.
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
- Make arguments explicit.
- All function calls must have same arity.
Sample Code
Wrong
Right
Detection
Detection is easy if language supports optional arguments.
Tags
Optional
Laziness
Conclusion
Be explicit. Favor readability over shorter (and more coupled) function call.
More info
The trouble with programmers is that you can never tell what a programmer is doing until it’s too late.
Seymour Cray
Discussion (0)