Remove Parameter
A parameter is no longer used by the method body.
“A parameter is no longer used by the method body.”
Clean up unused inputs.
graph LR
A[func(arg)] -->|Refactoring| B[func()]
When to apply (Smells)
- Dead Code: Params that aren’t used.
- Speculative Generality: “We might need this later”.
Motivation
- Simplicity: Shorter signatures are easier to read and use.
Mechanics (Steps)
- Check the method strictly doesn’t use the param.
- Remove it from signature.
- Update callers.
Explanation
Problem
Method calculate(date) doesn’t use date.
Solution
Change to calculate().
Pros and Cons
| Pros | Cons |
|---|---|
Code example
Typescript
Before
After
PHP
Before
After