...
For any given body of code, we can compute the minimum accessibility for each class and member that avoids introducing new compilation errors. The limitation is that the result of this computation may lack any resemblance to what the designer intended when the code was written. For example, unused members can obviously be declared to be private. However, such members could be unused only because the particular body of code examined coincidentally lacks references to the members. Nevertheless, this computation can provide a useful starting point for a programmer who wishes to minimize the accessibility of classes and their members.
Related Guidelines
Bibliography
Item 13, "Minimize the Accessibility of Classes and Members" | |
[JLS 2011] | |
Chapter 3, "Java Language Security Constructs" |
...