Hi all,
I am looking at adding next/previous setting behaviour to v1.3, but am 
finding the exact naming strategy is tricky. This refers to the Property 
classes on DateTime etc.

The code being added allows you to take a base date and set a value (ike 
setCopy) but forcing it tobe in the future. An example use isto get the 
date of next Tuesday, or the first of next month.

DateTime nextTue = dt.dayOfWeek().next(DateTimeConstants.TUESDAY);
DateTime firstOfNextMonth = dt.dayOfMonth().next(1);

Unfortunately, this isn't a simple one new method: Given a date, does 
'next Tuesday' mean that the date must be later than the start point or 
not? ie. if you request 'next Tuesday' on a date that is already a 
Tuesday should you move later or not? Both are valid business use cases.

Here as some possible method names:

Use method names - difficult to explain in the name:
  dt.dayOfWeek().withNext(TUESDAY); - nop if dt is Tue
  dt.dayOfWeek().withNextAfter(TUESDAY); - must be after dt
or
  dt.dayOfWeek().withNextValueThisOrLater(TUESDAY); - nop if dt is Tue
  dt.dayOfWeek().withNextValueLater(TUESDAY); - must be after dt
or
  dt.dayOfWeek().withValuePushingLater(TUESDAY); - nop if dt is Tue
  dt.dayOfWeek().withNext(TUESDAY); - must be after dt
or
  dt.dayOfWeek().withNextAllowCurrent(TUESDAY); - nop if dt is Tue
  dt.dayOfWeek().withNext(TUESDAY); - must be after dt

Use a flag - 'must be later':
  dt.dayOfWeek().withNext(TUESDAY, true);
or
  dt.dayOfWeek().withNextValue(TUESDAY, true);

Ignore the problem - client code must write an if statement:
  dt.dayOfWeek().withNext(TUESDAY);
or
  dt.dayOfWeek().withNextValue(TUESDAY);


I'm not sure which I prefer. I like short names, and the with prefix is 
a given. The withValuePushingLater/withNext combination is probably the 
most expressive, but 'pushing' is pretty yucky. I really dislike boolean 
flags, so I'd prefer to not do that, and leaving it to the client code 
seems to miss the point.

(Bear in mind that the correct name for setCopy is withValue)

But if you've any other ideas of method names, let us know.

Stephen


_______________________________________________
Joda-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to