T
Tony Morris
Dale King said:You are starting to sound like a kook. If you make statements that
disagree with conventional wisdom and don't provide anything to back
them up and claim that the conclusions are obvious to anyone then people
will think there really is nothing to back them up and that you don't
have any idea what you are talking about and won't take you seriously.
By the way coincidentally, the day of this conversation was I taking a
serious look at your JTiger API and thinking that it probably wouldn't
be too hard to hack the junit support in Eclipse into a JTiger plug-in.
But now that I read your extremist view I am not sure how seriously I
want to consider JTiger.
For the moment, I am giving you the benefit of the doubt and assuming
that you have latched onto a design principle that in general is often
true and tried to turn it into an absolute.
--
Dale King
P.S. since you don't provide an email address anywhere that I can find I
wanted to let you know that your Java trivia quiz had an error. The
question whose title was something about ice cream had the wrong answer
given. The answer says it is c and then goes on to explain why b is the
correct answer (which it is).
As much as I'm sure you'd like me to, I will not concede and provide a full
explanation, despite the bitching, and the "oh I'm not going to use JTiger
now because of you! So there!".
Being the optimist I am, I will attempt to invoke thought on your behalf
again.
I acknowledge that this will attract the usual criticism, but after a while,
I will ignore it, and it will all go away.
So here goes:
When you want an int wrapped in an Integer, you called a public constructor,
which is in violation of encapsulation rules.
Ask yourself, is really a new Integer that you want, or is it an object that
wraps an int?
I understand that the untrained eye will intrinsically tie these two
concepts together and recognising the distinction will require some thought.
So really, which is it? The answer is, the latter. You don't care how you
construct, you just care that when you pass, say 7, you can back something
that is an object representing 7. You, as a client, should be abstracted
from the process of construction.
Now, I know what the cynics and people with epileptic tongues are thinking
right now, but before you say it, I offer you one more thing to think about:
Consider the following code sample:
http://qa.jtiger.org/GetQAndA.action?qids=7
Most people will get this wrong first up - at least, the 20 or so I have
seen attempt it have never got it right first go (well done if you do).
The usual response to the correct answer is "wtf?" and then that person will
read the relevant part of the JLS, then reflect and determine that it is a
somewhat hacky attempt at caching (that's my perspective - yours may differ,
but in any case, ensure you clarify the situation).
Now this is the part where you will really have to think:
Do you suppose that this would have been different if instead, an API was
exposed that "constructed an object from an int" instead of what we
currently have, which is "construct a new Integer that represents 7"? Think
about it. If you're wondering how you can achieve this, I can certainly
provide an example. Whatever the case, I am not on my own - this has been a
well known fact for a very long time, and I'm sure that those of you who
possess initiative are capable of using google to discover an alternative
explanation.
And before you (yes you) start carrying on:
mv high-horse /dev/null
mv the-bitching /dev/null
cp thought .
Book pending.
--
Tony Morris
Software Engineer, IBM Australia.
BInfTech, SCJP 1.4, SCJP 5.0, SCJD
http://www.jtiger.org/ JTiger Unit Test Framework for Java
http://qa.jtiger.org/ Java Q&A (FAQ, Trivia)
http://xdweb.net/~dibblego/