T
Tony Morris
Dale King said:Tony Morris said:We already agree on the technical issues and are just arguing over
While you may be right in some respects, I cannot agree with this when the
topic is related, in any way, to computer programming. I teach Java (and
other things) at the local university - to make ambiguous, and in this case,
clearly incorrect, statements will confuse a lot of people. Do mammals lay
eggs "in a manner of speaking" ? Totally ambiguous (although there are two
mammals that DO lay eggs. aka monotremes) - if one didn't know better, what
is the answer to this question ?
Then it is perfectly valid to say that manner of speaking is likely to
confuse others, but that is not what you did. I would agree that it probably
is confusing to think that way.
A similar example that I have talked about many times here is the endless
topic of whether Java passes objects by value or reference. Of course the
technical answer is that Java never actually passes objects at all. One can
have a mindset that objects are actually passed and this will work in 95% of
the cases. People then come up with exceptions to explain the exceptions. As
I and others point out it is more confusing to have that mind set than just
learn it correctly.
I have made the effort to disprove that "instantiating an interface" is not
only syntactically incorrect, but a completely flawed methodology of
thinking, EVEN in a "manner of speaking".
And failed because it is a question over the meaning of words.
Since you seem to have the same misunderstanding, let's sort this out.
Sorry, I have no misunderstanding here. I understand exactly what Mat meant
and what you meant. I just thought your response to an obviously
non-technical, loose explanation was uncalled for. I am certainly not saying
that it is instantiating in the technical sense of the word.
Please answer the following:speaking"// Is this "instantiating a class X" ? ( "in a manner of
Let me answer with a question. Is this froobitzking the class X (in a manner
of speaking)? Can you answer that without knowing the definition of
froobitzking? Is there any meaning to your answer to the question if you
have a different meaning you ascribe to froobitzking? All you have pointed
out is that according to the technical definition, this is not froobitzking.
Given the disclaimer it is assumed that he is not using the technical
definition.
So what is the technical definition according to the JLS? According the JLS,
"We say that a class is instantiated when an instance of the class is
created by a class instance creation expression." I agree that by that
definition is not instantiating class X.
Let me rephrase Matt's statement. First let me change it from passive voice
to active voice first so I can make a proper substituting. Here it is in the
active voice:
Also, don't forget that you can also instantiate (in a manner of
speaking) an interface on the fly via an anonymous class
I haven't changed anything except change it from passive to active to make
it easier to substitute in grammatically. OK, now let me substitute in the
looser definition of instantiate that I think Matt was using:
Also, don't forget that you can also [create an object instance whose
type is that of] an interface on the fly via an anonymous class.
I dropped the disclaimer, because that statement is true even by the JLS.
The distinction here is between the use of the word type as opposed to class
see section 4.5.6 of the JLS. You are creating an object that is compatible
with the interface type, but it is not of the class of the interface.
So the manner of speaking that Matt is using is one that blurs the
distinction between the class of an object and the type of the expression.
In the case of an anonymous class the distinction is already blurred. I
would venture to say that the distinction is not that clear in the minds of
many Java programmers.
So in that manner of speaking Matt is correct. Whether that manner of
speaking is the best choice is a separate question.
It appears we have some common ground that we can agree on.
Regarding your analogy to Java passing by reference/value, it is a common
cause of confusion, and I don't think it is purely academic to suggest that
Java passes strictly by value. Java has only two types, Object
<b>references</b> and primitive types, all of which are passed by value. To
suggest otherwise (such as objects are "passed by reference") is not only
incorrect, but is so incorrect that it will cause problems for those who
believe it. Perhaps I'm just more of a "purist" ? (I hate stereotyping -
especially myself).
http://www.xdweb.net/~dibblego/javafaq/javafaq.html#q23
According to the definition given by the original poster, all of the
following are
"instantiating an interface in a manner of speaking":
String s = "blah"; // instantiating a java.util.Comparable
String s = new String("blah");
Integer i = new Integer(7); // java.io.Serializable
TableModel t = new javax.swing.table.DefaultTableModel();
Runnable r = new Thread();
The fact that they may look "syntactically different" to instantiating an
anonymous is irrelevant to the claim.
I cannot agree that this is "instantiating an interface" EVEN "in a manner
of speaking".
--
Tony Morris
(BInfTech, Cert 3 I.T.)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)
Sun Certified Programmer for the Java 2 Platform (1.4)
Sun Certified Developer for the Java 2 Platform