Menu

#62 Restrict visibility to class visibility

open
Bad marker (7)
5
2012-07-19
2011-08-29
Anonymous
No

This one is a bit more controversial: for instance, when an inner class is defined as private, then there's no need to say its members or methods should be private, even if technically their visibility can be reduced.
I have a lot of small classes, inner or package-limited, whose API is clean and who have a limited visibility only because it's not yet useful outside. For instance, having their getters public is really what I want (their class' visibility restricts them anyway), proposing me to set them private or package is technically correct but makes no sense as an API.

Discussion

  • Joerg Spieler

    Joerg Spieler - 2011-09-10

    You are right: Restrict visibility of methods or fields to to class visibility is technically ok, but does not make so much sense.

    I will include it in next version.

     
  • Anonymous

    Anonymous - 2011-09-12

    In fact it could be an option: strict mode => actual mode, where you propose really the minimal visibility, and standard mode => where you start by truncating the element's visibility to their class' visibility.

     

Anonymous
Anonymous

Add attachments
Cancel