Suppose I have a class like this:
public class Car {
private double distanceDriven;
public void drive(double miles){
distanceDriven += miles;
}
public void driveInCanada(double kilometer){
distanceDriven += convertToMiles(kilometer);
}
private double convertToMiles(double km){
return km*0.621371192;
}
}
You can see that convertToMiles
is:
- not using any instance variables
- is only used inside the class
Should it be declared as static? This does not change the functionality of the the function at all (see above). I think that it may affect:
- readability
- performance
- other?
Should the convertToMiles
function look like:
private double convertToMiles(double km){
or
private static double convertToMiles(double km){