Sign In/My Account | View Cart  

advertisement

AddThis Social Bookmark Button

Article:
  Making Sense of Java's Dates
Subject:   The Horror!
Date:   2003-06-05 04:54:32
From:   jimothy
The Calendar class is certainly a frightening mess of an API. What's worse is so many developers subscribe to the Gospel of Sun: Whatever Sun does must be right.


A few years ago, I was reviewing code written by a colleague, and, instead of multiple getXxx() and setXxx() methods, it had one get() and one set() method. I questioned him on why he chose this approach, and he replied, "This is what Sun does in the Calendar class." The impression I get is that he, and Sun, chose this approach out of laziness, even though the requisite getter and setter method could have easily been generated automatically.


The moral here is not new: You will write your code once, but it will be read many times. Take the time to make proper design decisions, or all will have to suffer.

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • The Horror!
    2003-06-08 21:12:40  anonymous2 [View]

    I think most of the Calendar code is a C port that was donated by IBM. That's the only excuse I can think of for the API being so awkward and definitely not idiomatic Java. Can anyone confirm or deny?
    • The Horror!
      2003-06-08 22:33:10  anonymous2 [View]

      The code in the current Java Calendar classes was originally developed by Taligent and donated to Java when Taligent was aquired by IBM. Taligent had originally been a C++ company. The first of the references: "International Calendars in Java at IBM" gives more details. Ph.