...
| Wiki Markup |
|---|
*EX2:* "if a class is package-private or is a {{private}} nested class, there is nothing inherently wrong with exposing its data fields - assuming they do an adequate job of describing the abstraction provided by the class. This approach generates less visual clutter than the accessor-method approach, both in the class definition and in the client code that uses it." \[[Bloch 08|AA. Java References#Bloch 08]\]. This exception applies to both mutable as well as immutable fields. |
EX3: Static final fields that contain values of mathematical constants may be declared public.
Risk Assessment
Failing to declare data members private can break encapsulation.
...