Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calendar.MONTH returns 2 its March now




On Mar 24, 2005, at 7:39 AM, Rolf Howarth wrote:

At 2:42 am -0800 23/3/05, Glen Ezkovich <email@hidden> wrote:

 The documentation actually does say explicitly that Calendar.JANUARY
 == 0:

http://java.sun.com/j2se/1.4.2/docs/api/java/util/ Calendar.html#MONTH

"The first month of the year is JANUARY which is 0"

Yes but not what any other month is. Additionaly no mention is made as
to the ordering. You are left to assume the sequence. Is FEBRUARY 1, -1
or is it 4? Is MARCH 2, -1 or is it 8?

Principle of least confusion. All other things being equal, assume things are the most obvious.

Fine, all things being equal.

I hope I don't ever have to use any of your libraries if you think it's ok to define the constants in a different order just because the spec doesn't say you can't!

Frankly, I have modeled months as objects and not ints. That way methods are used to easily order and manipulate months. Calendars create their own years and years create their own months and months create their own days, etc. Currently, the package uses GregorianCalendar to do the hard work, It just provides a simpler interface with which to interact.


All I said was that it could be done, not that I thought it was OK. I have seen some very bad code that works just fine created by overly clever geniuses.

I was just making the point that is is a mistake to assume anything about the implementation of a class and to assume that the implementation will never change. Unfortunately, the communication skills of software developers are, in general, lacking and one is forced to assume things about their APIs.



Glen Ezkovich
HardBop Consulting
glen at hard-bop.com



A Proverb for Paranoids:
"If they can get you asking the wrong questions, they don't have to worry about answers."
- Thomas Pynchon Gravity's Rainbow


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Calendar.MONTH returns 2 its March now (From: Rolf Howarth <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.