public class Tester {
private double length;
private double width;
private double height;
public Tester(double ________1, double _________2, double _________3){
length = _________1
width = _________2
height = _________3
}//Tester constructor
}//Tester class
Above is a simple sample code and I was wondering if there is a "good" naming convention for naming variables when making classes?
For example what would be good names for _____1, _____2, _____3?
Would it be something like testerLength, testerWidth, testerHeight?
The names of the arguments should be very meaningful, because you will see them in the Javadoc. You have multiple options here, I will give you an example for a few:
an a
before every argument:
public Tester(double aLength, double aWidth, double aHeight) {
length = aLength;
width = aWidth;
height = aHeight;
}
as @Cyber mentioned: using an _
:
public Tester(double length, double _width, double _height) {
length = _length;
width = _width;
height = _height;
}
and my personal favorite, just use the same name and the scope:
public Tester(double length, double width, double height) {
this.length = length;
this.width = width;
this.height = height;
}