Sort Map on Value

L

Lew

Lew wrote :
Now you are just getting snarky. Like you I have been doing this for
over 30 years in more languages than I can remember. I realize the
importance of reading docs and so on.

Snarky? Moi? Gods forfend!
But in the midst of a coding haze I do not always break off to read
docs. The assumption is that the name of the class/method/parameters
makes sense, and all the requirements are exposed at the code level.

AFAIK this is the first time that I have been bitten by this assumption.

You aren't the only one to run into trouble because you didn't double-check
the Javadocs.

On a major project I was working on last year, I ran across problems in the
client codebase due to programmers not double-checking the docs for
java.util.Calendar#clear().
<http://java.sun.com/javase/6/docs/api/java/util/Calendar.html#clear(int)>

They were making calls like 'calen.clear( Calendar.HOUR )' with the intention
of zeroing the hour field of the Calendar object pointed to by 'calen'. Alas,
they did not read the Javadocs, so they introduced a bug where the object lost
track of its time zone.

See, 'clear()' doesn't do the obvious thing, it
"ets the given calendar field value and the time value (millisecond offset
from the Epoch) of this Calendar undefined."

Yep, undefined. Not zeroed.

Because I am so very anal about reading Javadocs, I was the one who discovered
this bug and provided a fix. Maybe this is because I have learned the hard
way that with the Java API one should never take anything for granted. Not
even a class I'd been using for nearly ten years.
 
W

Wojtek

Eric Sosman wrote :
Sorry: It was just my attempt to let Wojtek know how irritating
a misattribution can be, by addressing him with a name other than his
own. I tried to be witty; I succeeded only half-way and am therefore
half-witty.

My apologies. I took a snippet and removed two levels of quoting, and
inadvertantly made you the author.
 
A

Arved Sandstrom

You aren't the only one to run into trouble because you didn't double-check
the Javadocs.

On a major project I was working on last year, I ran across problems in the
client codebase due to programmers not double-checking the docs for
java.util.Calendar#clear().
<http://java.sun.com/javase/6/docs/api/java/util/Calendar.html#clear(int)>

They were making calls like 'calen.clear( Calendar.HOUR )' with the intention
of zeroing the hour field of the Calendar object pointed to by 'calen'. Alas,
they did not read the Javadocs, so they introduced a bug where the object lost
track of its time zone.

See, 'clear()' doesn't do the obvious thing, it
"ets the given calendar field value and the time value (millisecond offset
from the Epoch) of this Calendar undefined."

Yep, undefined. Not zeroed.

Because I am so very anal about reading Javadocs, I was the one who discovered
this bug and provided a fix. Maybe this is because I have learned the hard
way that with the Java API one should never take anything for granted. Not
even a class I'd been using for nearly ten years.[/QUOTE]

I think you could make a pretty decent argument that any method named
clear() ought to be investigated in the Javadocs. After all, when you
think about it, for some objects there is an intuitive meaning for that
name, but for many others (like Calendar) there is not.

reset() would be another example.

AHS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,187
Latest member
RosaDemko

Latest Threads

Top