Frequently Asked Questions about the Time and Money Code Library
Why use static creation methods instead of constructors?
More communicative, when you give it a name (which I will do more as
I refine).
Don't have to expose the concrete type. Can put methods on class high
in the hierarchy and instantiate any concrete implementation. (Which I
actually did more in the past, but the current hierarchy is pretty flat).
Can do computations to construct variations. (e.g. the
Duration.days(), Duration.months() etc.)
My preference is to use constructors only for the lowest level creation:
These are the attributes that must be provided to create a valid
instance of this class, and this constructor is just going to stuff them
into instance variables. Anything more involved, I prefer to handle
elsewhere.
Why is CalendarDate a subclass of CalendarInterval?
Conceptually and functionally, the date is an interval, rather than an instant in time. The transformation from a CalendarInterval to a TimeInterval, using a TimeZone, is exactly the same as a CalendarDate.