How many times do we see lazy argument names?
TL;DR: Name your arguments according to the role and not the accidental position
Intention Revealing Names
- Use meaningful names
When writing methods, we usually don't stop to find decent names.
We never refactor the obvious, neither.
class Calculator: def subtract(self, first, second): return first - second class CalculatorTest: def test_multiply(): assert equals(first, second)
class Calculator: def subtract(self, minuend, subtrahend): return minuend - subtrahend class CalculatorTest: def test_multiply(): assert equals(expectedValue, realValue)
We can warn for forbidden words like 'first' and 'second' as argument names.
Always follow rule suggesting parameter.
Name your collaborators according to the role.
Final source code is the real software design.
This article is part of the CodeSmell Series.