Matt Gerrans
Posts: 1153
Nickname: matt
Registered: Feb, 2002
|
|
Re: error?
|
Posted: Mar 22, 2004 2:12 PM
|
|
Don't worry, twc, the form you suggested would be quick and easy to fix with the help of the compiler. In fact it would be better than the original one-liner, which, as exemplified by Lynn's quandry, was too cryptic. Moreover, if the three-method pile-up did have some error, it would be harder to debug.
As far as the style goes, I think your example is quite good. In fact, it is so clear, it doesn't need any comments; it is self-documenting. The only argument against it would be the old premature optimization canard that you are creating unnecessary variables. Even that claim may be false, since temporaries will need to be created anyway (the actual difference may be JVM-dependent and the good JVMs would probably optimize both styles down to the same set of operations).
This self-documenting style is especially useful -- even better than comments -- in this case, where both of the getTime() methods seem to be misnamed. As far as I'm concerned, since neither of them returns a 'Time' object, neither should be called "getTime()" -- the fact that they both return something different is even more confounding. It seems like they should be named getDate() (yes Adam, your psychic powers are intact) and getMilliseconds(), respectively, or something along those lines.
|
|