OOP.APROF
Avoid "protected" instance fields
Description
This rule flags any "protected" instance field.
Instance fields are an implementation detail of your class. It is good practice to hide such implementation details from users of your class. Instead, provide the user with methods to access and/or change such fields.
Example
package OOP;
class APROF {
private int c = 14;
protected int a = 10; // Violation
}
Repair
Declare the field "private" and provide access methods to the field if needed.
Reference
Haggar, Peter. Practical Java - Programming Language Guide. Addison Wesley, 2000, pp.170 - 173.
|