Re: Separate interface and implemenation problem..
MRe wrote:
It would be nice if Java allowed protected (or private) modifiers
inside an interface [why doesn't it?]
In addition to what Eric wrote (infra), it would, a), violate the
definition of 'private', and, b), violate the definition of an
interface.
By design, 'private' means "that which the outside world should not
ever know". By design, an interface publishes "exactly what the
outside world must know". They are exact opposite concepts.
Your problem isn't that interfaces don't publish private members.
Your problem is that you want to publish a private member and still
call it 'private'. If you want to publish it, it ain't private!
Eric Sosman wrote:
Because they'd either (1) be useless, (2) break the access
model, or (3) postpone access errors to run-time:
....
I guess you mean `new TreeNodeImpl()'.
MRe wrote:
Ha, yes. I always forget to type that operator. Why is it even in the
language; when is the class constructor ever referenced, except after
new?
What is the use of complaining that it's there?
Regardless, the 'new' is there to distinguish constructors from
methods.
Every computer language has its little syntactic quirks. If the 'new'
operator weren't there, then you'd have a problem with constructors
and methods looking much alike. Then people would whine, "Why isn't
there something like a 'new' operator to make it clear what's a
constructor and what's a method?"
I have a brilliant idea: why don't you learn the Java language as it
actually is? That is, how about using the power of the language
instead of resisting it and trying to reduce it to your current level
of understanding?
There's no question that Java is not quite a perfect language. There
is, to my knowledge, no perfect computer language. However, perfect
or not, there is a purpose to just about everything in Java.
Unfortunately, or rather fortunately, that purpose does not include
accommodation of every little thing you personally would prefer in a
language.
I have discovered with experience over many computer languages, and in
particular with Java after some years of use, that idioms that seem
verbose or kludgey or complex (generics comes to mind) have a power
and a usefulness that arises from the very verbosity or seeming
kludginess or apparent complexity. It pays to master the language
features as given before whining about them. Only then can you gain a
proper perspective on what can be improved.
--
Lew