I agree with "If a parameter is part of the 'state' of the class, then use a private member", but that immediately brings a new question: when a parameter is consider part of the state of the class?
Just to compliment what has been said, I would add:
A parameter is part of the state of the class if after the call to the method we need to keep the value.
Example 1 The parameter is not part of the state of the class.
The class Car doesn't have any reason to remember what key was used to start the car.
Class Car{
Lock lock;
[...]
public boolean startCar (Key keyUsedToStart){
return (canStartCarWithThisKey (keyUsedToStart));
}
private boolean canStartCarWithThisKey (Key keyUsedToStart){
return (lock.canStartCarWithThisKey(keyUsedToStart));
}
[...]
}
Example 2 the parameter is part of the state of the class.
The class Car needs to know how much fuel it has.
Class Car{
Fuel fuel;
[...]
public void putSomeFuel (Fuel fuelToAdd){
this.fuel.add(fuelToAdd);
}
[...]
}