L
Lew
Lew wrote :
Snarky? Moi? Gods forfend!
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.
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
"
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.