On Sun, Feb 14, 2010 at 9:46 AM, Sean Owen <sro...@gmail.com> wrote:
>
> I think final is a must on static fields, except in a few exceptional cases.
> While it doesn't mean immutable it expresses something useful and makes
> static sins harder to commit.
>
> I feel similarly about instance fields where possible. Instance fields which
> hold state must be mutable, but fields which refer to sub-components should
> not. A Car should have a mutable fuel level, but its Engine should not be.
>
> I find these two practices useful enough to suggest they should be enforced.
>
> I am also a big fan of declaring classes (or more narrowly, certain methods)
> final by default. Design for extension or prohibit if says the wise Reverend
> Bloch. But this isn't something I'd actively foist on anyone since it needs
> judgment about design intent.

Chiming in on this late.

+1 on all of these points (final on statics, final on non-stateful
instance fields, final on classes by default. I first came across this
style in lucene many years ago and though it frustrated me at the
time, I clearly see the wisdom in doing so).

+0 for finals on method parameters. I understand why this is a good
idea, but I find that it generally effects readability.

Reply via email to