[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bindings and assignments (was: Re: continuations)
> 1. What do the main Java texts/books say about this? Do they (a)
> emphasize its existence, (b) provide useful guidelines on its use and,
> (c) most importantly, use it frequently in their own sample code so
> programmers will imbibe this discipline?
>
> 2. Do practicing programmers use it much? If, for instance, you were
> to search through your own code base, or libraries from Sun, or code
> on Alphaworks, would this appear often? (I could search this myself,
> except that I want only this use of final, not the one for classes,
> and I don't have a Java parser handy to mock this up.)
This article:
Java theory and practice: Is that your final answer?
http://www-106.ibm.com/developerworks/java/library/j-jtp1029.html
suggests, unsurprisingly, that immutable fields are a relatively
underused feature, and not practically documented. (The most relevant
section is the one entitled "Final fields.") And the article doesn't
even mention final locals/parameters. I imagine, though I don't have
statistical evidence, that the requirement of declaring local variables
to be final in order to reference them within anonymous inner classes
(closures) is almost entirely unknown and unused in practice.
Dave