Objects by Design Forums Here you can view your subscribed threads, work with private messages and edit your profile and preferences Registration is free! Calendar Find other members Frequently Asked Questions Search Home  
Objects by Design Forums : Powered by vBulletin version 2.3.5 Objects by Design Forums > Main Forums > Object-Oriented Design and Patterns > Suntimes / Zmanim Calendar
  Last Thread   Next Thread
Author
Thread Post New Thread    Post A Reply
Eliyahu
Junior Member

Registered: Apr 2001
Location:
Posts: 3

Suntimes / Zmanim Calendar

Hi,
I am in the process of writing an API that can calculate sunrise/sunset as well as related time calculations (zmanim).

One of the design goals was to make this an API that can easily be used by other programs. I had a number of questions regarding the design. I extended GregorianCalendar for my main class since I felt that my class is just a calendar with additional methods. This allows someone to create an instance and then use the regular Calendar methods to change the date of calculation. Often a chart for a given location is generated for a whole year. This can easily be accomplished by looping and incrementing the calendar. Should I have just had a local Calendar aggregated within my class?

The overall design is as follows:

The SunCalendar class extends GregorianCalendar. It adds methods such as getSunrise(), getNauticalTwilight() etc. It is not using a bean pattern and all values from these methods are generated dynamically and returned as a Date object.

SunCalendar is then extended by ComplexSunCalendar that returns multiple but not often requested times such as 8 different calculations for dawn.

The actual astronomical calculations are in concrete classes that implement the AstronomicalCalcEngine interface. This was to allow easy swapping of different algorithms. A GeoLocation object contains location name, longitude, latitude and timezone that are used for the calculation.

I would appreciate any design suggestions and recommendations.

Thanks

Report this post to a moderator | IP: Logged

Old Post 06-01-2004 10:11 PM
Eliyahu is offline Click Here to See the Profile for Eliyahu Click here to Send Eliyahu a Private Message Find more posts by Eliyahu Add Eliyahu to your buddy list Edit/Delete Message Reply w/Quote
SZ
Administrator

Registered: Apr 2001
Location: New York
Posts: 492

Thumbs up

This sounds like an interesting project!

There are times when aggregation is recommended over inheritance. I like the old 'IS-A' rule to prove the usage of inheritance. This usually means that a client of the derived class would use the class in much the same way as the superclass. If ComplexSunCalendar IS-A SunCalendar and SunCalendar IS-A Calendar, then your design is correct.

It would help to see a class diagram of your application to get a clearer picture.

Report this post to a moderator | IP: Logged

Old Post 06-02-2004 12:18 PM
SZ is offline Click Here to See the Profile for SZ Click here to Send SZ a Private Message Visit SZ's homepage! Find more posts by SZ Add SZ to your buddy list Edit/Delete Message Reply w/Quote
ddrillich
Junior Member

Registered: Jan 2004
Location:
Posts: 20

Good Day,

BTW, http://www.agilemodeling.com/artifacts/classDiagram.htm says: "UML 2 no longer supports the concept of aggregation, a weaker form of composition, which was depicted in UML 1.x using a hollow diamond."

Regards,
Dan

Report this post to a moderator | IP: Logged

Old Post 06-02-2004 05:34 PM
ddrillich is offline Click Here to See the Profile for ddrillich Click here to Send ddrillich a Private Message Find more posts by ddrillich Add ddrillich to your buddy list Edit/Delete Message Reply w/Quote
VOM
Junior Member

Registered: Sep 2003
Location: Boulder, CO
Posts: 16

That doesn't sound right. Those book writers are not always right<g>. Aggregation is still present in the OMG's UML 2.0 Superstructure spec. See page 80 (which shows aggregationKind as none, shared or composite) and page 130.

Report this post to a moderator | IP: Logged

Old Post 06-03-2004 06:39 PM
VOM is offline Click Here to See the Profile for VOM Visit VOM's homepage! Find more posts by VOM Add VOM to your buddy list Edit/Delete Message Reply w/Quote
Eliyahu
Junior Member

Registered: Apr 2001
Location:
Posts: 3

It has been a while but here is a slight update. The GPL code is available at http://www.kosherjava.com . I currently do not have the tools to generate a class diagram, but you can generate them directly from the source code. It is currently using inheritance and not aggregation though this is not something complex to change. You can see the inheritance tree best by viewing the ComplexZmanimCalendar JavaDoc .
Any comments would be welcome.

Report this post to a moderator | IP: Logged

Old Post 06-23-2005 08:45 PM
Eliyahu is offline Click Here to See the Profile for Eliyahu Click here to Send Eliyahu a Private Message Find more posts by Eliyahu Add Eliyahu to your buddy list Edit/Delete Message Reply w/Quote
All times are GMT. The time now is 03:09 AM. Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 

< Contact Us - Objects by Design >

Powered by: vBulletin Version 2.3.5
Copyright ©2000 - 2018, Jelsoft Enterprises Limited.
Copyright 1999-2005, Objects by Design, Inc.