Sorry for short replies. Tapping this on a phone.

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.
In fact I have been making such changes regularly.

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.

I actually used to write method params final by default but stopped, even
though I like what it promotes. Nobody is pushing that though.

Sean

On Feb 13, 2010 9:18 PM, "Ted Dunning" <ted.dunn...@gmail.com> wrote:

I find it mildly expressive to be able to say:

   public static final String KEYWORD_CONSTANT = "foobledy foo";

My reader will know that this is a constant that is safe to use as such.

Other than this and the syntactic captured variable case, I don't use final.

On Sat, Feb 13, 2010 at 1:05 PM, Benson Margulies <bimargul...@gmail.com
>wrote:

> That doesn't, sadly, prevent > > x[2] = 1; > > So, to me, final is too
weak to be useful. I pu...
--
Ted Dunning, CTO
DeepDyve

Reply via email to