Discussion: Recurrence Rules - Part 3

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Discussion: Recurrence Rules - Part 3

Adrian Crum
After spending more than a week trying to fix and improve the recurrence
rules, I finally gave up. I'd like to propose an alternative
implementation to the community and see if it would be worthwhile to try it.

The recurrence system I set up on my local copy works well. It is based
on a design proposed by Martin Fowler -
http://martinfowler.com/apsupp/recurring.pdf. His design is quite old,
so I updated it to support internationalization and I expanded it.

The design is extremely flexible and it allows for arbitrarily complex
recurring events. The design is based on temporal expressions. Each
temporal expression could be considered a rule - like "every Monday" or
"the 15th of the month."

Temporal expressions can used alone or they can be combined in any of
three "collection" expressions - Union, Intersection, and Difference. A
date will match a Union collection if any of its expressions match
(logical OR). A date will match an Intersection collection if all of its
expressions match (logical AND). A date will match a Difference
collection if it matches the "included" expression and doesn't match the
"excluded" expression.

Using Bilgin's Happy Hour promotion as an example:

Intersection
   DayOfWeekRange(Monday, Friday)
   TimeOfDayRange(15:00, 17:00)

Let's say we want to exclude St. Patrick's Day from the Happy Hour
promotion:

Difference
   Include
     Intersection
       DayOfWeekRange(Monday, Friday)
       TimeOfDayRange(15:00, 17:00)
   Exclude
     Intersection
       MonthRange(March, March)
       DayOfMonthRange(17, 17)

A semi-monthly payday:

Union
   DayOfMonthRange(1, 1)
   DayOfMonthRange(15, 15)

Labor Day (US):

Intersection
   MonthRange(September, September)
   DayInMonth(Monday, 1)

A schedule is made up of schedule items. Each schedule item "points to"
a temporal expression. It also has duration information, and an item
type ID (meeting, appointment, etc).

Schedules can be linked to parties/facilities/fixed assets through
relationship entities.

The implementation requires three new entities and an optional fourth. I
could write a conversion routine to convert the existing Recurrence*
entities over to the new ones.

If there is any interest, I could provide a preliminary patch for
evaluation.

Comments are welcome.

-Adrian