OOP.LPF
List all "public" and package-private methods/data first
Description
This rule flags code that does not list all "public" and package-private methods/data first.
It is a good habit to order the methods and data in a class so that all "public" and package wide information is presented first, followed by the "protected" and "private" information. This way, the user of your class will find the accessible methods directly underneath the class declaration, and will not be bothered with implementation details described by "private" and "protected" data/methods.
Example
package OOP;
class LPF {
private int method () {
return 2;
}
int method2 () {
return 3;
}
}
Repair
Reorder the list of methods/data in your class.
|