A New ObjectOriented Model of the Gregorian Calendar
A New Object-Oriented Model of the Gregorian Calendar
Problem Presentation n Time Domain is pervasive n n Cross Cutting Related with Financial Domain Related with almost every Domain… We concentrated our work on the Gregorian Calendar
Gregorian Calendar n Main Design Challenges n Irregularity n n Comparing n n January < July January first < February twentyninth 3 months < 1 year or 5 days < 1 week Distance n n Months have 28, 29, 30 or 31 days Leap years Associated with natural events (i. e. day/nigth, seasons, earth movement, etc. ) (January distance. To: July) = (January, 2005 distance. To: July, 2005) Time line filtering n n n working. Days includes: (January first, 2005) working. Days from: (April first, 2005) to: (April thirty, 2005) 14 days from: (April first, 2005) counting: working. Days
Current Models’ Limitations n Lack of abstractions n n Abstractions not matching reality n n n a. Calendar. set ( Calendar. MONTH, 1) (Does this mean January? ) Calendar. get. Instance () (Are calendar a singleton? ) These problems show lack of understanding, they provide a poor domain language, therefore: n n Squeak: Date dates (There are no days in a date time…) Some models have one, or a few, general purpose abstractions n n Smalltalk-80: #Monday < #Friday (It returns false) It is difficult to express common situations with them They are difficult to learn They offer different possible interpretations These problems imply: n n n Ad-hoc implementations Code duplication Error prone situations
Matching Reality M M R ? April first 01/01/2005 ? April 2005 April first a. Calendar 01/01/2005 April 2005 Smalltalk-80 M R 01/01/2005 R Java /. Net M R April first 01/01/2005 April 2005 Squeak The Best Solution
Our Metaphor Year Granularity Year 2005 Year 2007 Jan. 2005 July 2005 Dec. 2005 01/07/05 15/07/05 31/07/05 Year 2003 Zoom in Month of Year Granularity Zoom in Date Time Granularity 15/07/05 00: 00 12: 00 15/07/05 23: 59
Main Abstraction
Year Granularity Gregorian. Year number: 2005. Y 2005 Gregorian. Year number: 2004. Y 2004
Month of Year Granularity y 2005 april April, 2005 April 2005 Y 2005 April of: 2005
Date Granularity April first, 2005 01/04/2005 April 2005 1
Date Granularity 14 days from: (April first, 2005) counting: working. Days a. Rel. Date 01/04/2005 a. Timespan 14 days
Date Time Granularity (April first, 2005) at. Noon a. Date. Time 01/04/2005 12: 00
Recurrent Time Entities n Month January April February
Recurrent Time Entities n Day of Month n n n Day of Week n n n January first December twenty. Fifth Monday Tuesday Time of Day n n Time. Of. Day noon Time. Of. Day hours: 10 minutes: 11
Time measurements and Their Relevance January distance. To: February January, 2005 distance. To: February, 2005 1 month 1 5 5 years year (Gregorian. Year number: 2000) distance. To: (Gregorian. Year number: 2005)
Measurements n n n Generic Model Will be presented at OOPSLA 2005 Examples: n n n n 1 year + 6 months 18 months 3 months + 5 days (A “Bag”) 5 days + 3 weeks 26 days 1 day + 1 hour 25 hours 0. 10 / 1 year Yearly Interest Rate of 10 % 40 km / 1 hour Speed 40 km / 1 hour * 2 hours 80 km
Time Units n Gregorian calendar irregularity month year decade Base Units day century week second Derived Units hour minute millisec.
Intervals January, 2005 to: November, 2006 by: 2 months Jan 2005 an. Interval Nov 2006 2 month
Segments n Absolute and Relative a. Timespan 01/01/2005 the. Beginning. Of. Time the. End. Of. Time -15 days
Time Line Filtering 14 days from: (April first, 2005) counting: working. Days a. Timespan 01/04/2005 a. Rel. Date 14 days working. Days non. Work. Dys
Conclusions n n Object model of the Gregorian calendar Metaphor: Different resolution points of the time line n n n n Total order between time points Distance Move from one point to another Move between points of different resolution Representation of time line segments and intervals Generic Measurement Model to reify Time Measurements Time line filtering allows Relative points in time Abstractions for time entities such as a day, a day of a month and months.
Future Work n n n Time zone support Expand Timespan protocol New abstractions like Hour, Minute, etc. (not units) Reify time lines Allow relative points of any granularity
Questions
- Slides: 23