Hi guys,
if I have the following private member:
private int xIndex;
How should I name my getter/setter:
getXindex()
setXindex(int value)
or
getxIndex()
setxIndex(int value)
EDIT: or
getXIndex()
setXIndex(int value);
?
Hi guys,
if I have the following private member:
private int xIndex;
How should I name my getter/setter:
getXindex()
setXindex(int value)
or
getxIndex()
setxIndex(int value)
EDIT: or
getXIndex()
setXIndex(int value);
?
getXindex()
I always use first letter upper case after "get" keyword.
EDIT : I am convinced :D getXIndex()
wins!
I would use:
getXIndex()
setXIndex(int value)
Consider also renaming the variable to indexX
.
I think getXindex()
is the best way. The getter should start with 'get', followed by the member name, with its first letter capitalized. Also the latest conventions I heard of, say that we should avoid multiple capital letters one after another. For example getHTMLtooltip
is wrong. it should be getHtmlTooltip
instead. Also you should try to make all your members final
and there should not be a need of setters, since the class will be immutable ;)
Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized.