IG: Public Field Issue

The following code:

public final boolean preFuser;

public final int hashcode;

comes up as violating encapsulation.

In general we discourage public mutable variables, but public final variables are allowed in some circumstances.

Are there reasons for not allowing this that I might be unaware of? Or would an option to allow non-static final variables be acceptable.

Thanks,
Mike

2 comments
Comment actions Permalink


Hmm, that's not a pattern I've seen before, but I understand the argument. Certainly public non-static finals violate many coding standards, so I wouldn't allow them by default, but I could see value in having a flag. Submit it as a tracker item, please, so I don't lose it.

--Dave Griffith

0
Comment actions Permalink


Hmm, that's not a pattern I've seen before, but I
understand the argument. Certainly public non-static
finals violate many coding standards, so I wouldn't
allow them by default, but I could see value in
having a flag. Submit it as a tracker item, please,
so I don't lose it.

--Dave Griffith


http://www.intellij.net/tracker/idea/viewSCR?publicId=37361

Done

0

Please sign in to leave a comment.