Re: List or Iterator
Mike Schilling wrote:
I might as well make it a full-fledged nested class." Anyway, had
local classes never been invented, I doubt we'd miss them.
There was a reason why they were added to the Java language.
Obviously somebody missed them.
Mike Schilling wrote:
No one's stepped up and said "I created one, even once". So your
argument is that we'd miss something we don't use.
Your logic is utterly fallacious. That is not my argument, and I'll
thank you not to put words in my mouth.
No one *in this newsgroup* has stepped up, so far. That proves only
that no one in a particular limited population has used them, yet.
Given that how many readers here are still learning what nested
classes even are, let alone local classes, and that the readership
here is not a comprehensive, random or representative sample of Java
programmers, that proves exactly absolutely nothing except that many
of us are still learning.
One respondent has already provided valid scenarios where local
classes would be useful, e.g., as a cleaner way of doing things than
with anonymous classes. This doesn't prove anything either, but it
does point to the possibility that somebody would miss them. Also,
now that we're discussing local classes, there's a good chance that
someone who heretofore didn't know of the feature, as another
respondent has already admitted, will begin to do so.
For the record, my argument is that someone did find local classes
useful, oh, twelve or so years ago, since the powers that be went
through the trouble to add the feature to Java. That is pretty strong
evidence that there was a use case for it, since an awful lot of
arguably useful features were not added to the language, yet that one
made the cut early on. Is your argument that it was added even though
no one felt a need for it? Or that they shouldn't have added it then
because no one in a small group attached to a particular news group
twelve years later would see the value, or even be aware of the
I've also begun to see more value in the feature myself, now, and plan
to start to use it. A colleague of mine pointed out that the named
local class idiom is actually easier to read and more self-documenting
than the anonymous class idiom. His arguments are strong, if not
overwhelming, and given the rampant ignorance around inner classes in
Java generally, using such a thing to help readability is likely to
help maintainability of the code.