I have a general Java question that I am looking for an answer to. Suppose I have an object with a property height, and I have a method that uses height to calculate. Is it better to pass the height of the property to the method or not to pass the complete object and use the getter to get the height value. Hope this makes sense.
eg.
public getHeightInMeters(Object object) {
return object.getHeight()*x;
}
- is it the same, worse, better than?
public getHeightInMeters(Height height) {
return height*x;
}
source
share