Why would there be an advantage to use a static method and pass the reference to an object as a parameter rather than calling the method on an object?
A clarification on what I mean may be found in the following class:
public class SomeClass {
private double someValue;
public SomeClass() {
// Some constructor in which someValue is set
}
// Called on an instance
public void incrementValue() {
someValue++;
}
// Static method with parameter pass
public static void incrementValue(SomeClass obj) {
obj.someValue++;
}
}
My question is not restricted to this class alone; any point where you'd pass an object instead of calling it on a method is what I'm interested in. Is this ever advantageous? If so, why?