NAMING.GETA
Accessor method names should start with 'get'
Description
This rule flags any accessor method that has an unconventional name format.
A getter method's name should start with 'get' unless it returns boolean. If it returns boolean, it should be prefixed by 'is'.
Example
package NAMING;
public class GETA {
public int method() { // violation.
return _count;
}
private int _count = 0;
}
Repair
Change accessor method name to 'get<field name>'.
package NAMING;
public class GETA {
public int getCount() {
return _count;
}
private int _count = 0;
}
Reference
http://www.AmbySoft.com/javaCodingStandards.pdf
|