On Wed, 13 Oct 2010, Peter Duniho wrote:
> Tom Anderson wrote:
>> On Wed, 13 Oct 2010, Spud wrote:
>>
>>> Does the final keyword serve any purpose, except to make constants
>>> constant?
>>
>> Does the type of a variable serve any purpose?
>>
>> final, like types, doesn't let you do anything you couldn't do without it.
>
> I suppose that depends on your definition of "couldn't do without it".
>
> The "final" keyword is required in order to use local variables in anonymous
> classes.
True, i'd forgotten about that. And about the fact that it guarantees
cross-thread visibility of assignments in constructors. Both of those are
uses of a different (or additional) character to the kind i was thinking
of.
>> If you find you don't tend to do things you didn't mean to do, then you
>> won't find final very useful. But if you find that you sometimes do,
>> or, more likely, if some other unspeakable scoundrel who works on your
>> codebase does, then perhaps you might.
>
> Thankfully, it doesn't happen often. But I've certainly been known to
> do things I didn't mean to do, and I consider myself one of the more
> careful programmers. I like being able to mark something as "final"
> when appropriate.
Agreed; i like final myself, although not as much as some people. I use it
a lot for fields, but not so much for locals.
tom
--
you can't feel your stomack with glory -- Czako
|