Here's a quick stab at the problem: If you wanted to know what events where being held at a specific venue, you could write a method in the venue object that would return event objects at that venue. If you wanted to know what events were being held for a particular venue at a particular time, you'd create another method that would take a timeslot object and then give back a bunch of event objects.
You'd then iterate through the events, and then get their timeslot object. The timeslot object could be somewhat trickier. You could make a base timeslot class, and derive timeslot classes for each time that you'd mentioned. But I'm actually not sure how "correct" this approach would be. For insertion, you could create: event.add(object venue, object timeslot); venue.add(object event, object timeslot); But if I were you, I'd wait for Sean Corfield to pipe up :) ----- Original Message ----- From: Jim Davis <[EMAIL PROTECTED]> Date: Thursday, September 18, 2003 2:35 pm Subject: RE: OO modeling Hell > I think I misrepresented my problem. > > The objects are "virtual" - they have no database access themselves > (this is handled, as you suggest, by separate implementation classes, > which handle all persistent data access). > > The problem I'm having is that in the procedural world I'm coming > from I > would have a big run which returned, for example, all the events > takingplace at a Venue. > > In the object world, after all this stuff has been instantiated and > cached, I'm having trouble connecting the objects together. In this > specific case an Event can have several TimeSlots each at its own > Venue,a Venue can have many events and a Timeslot can have many > Events. > In use all of this information will actually be stored as cached > objectsin memory - there will be no DB calls. This is possible > because of the > (relatively) small size of the total dataset (about 200 events at some > 70 venues) and should increase performance significantly. > > My old version of the system simple loaded all of the data into > persistent (application scoped) queries and the application pulled it > from there using QofQ. > > Thinking in objects I'm not sure how to translate that... > > Am I confusing everybody else as much as I am myself? ;^) > > Jim Davis > > > -----Original Message----- > > From: Shawn Grover [EMAIL PROTECTED] > > Sent: Thursday, September 18, 2003 3:56 PM > > To: CF-Talk > > Subject: RE: OO modeling Hell > > > > I think you are on the right track but missed the business rules end > of > > OO. > > > > I would do the same as you - create objects for dealing with my > underlying > > tables. I call these objects "data access components", and normally > store > > them in a different folder called data. Now, you have the concept > that an > > event, venue, and a time slot are related. This is a business rule. > In > > this case, I create another object that will implement the business > rules. > > In your case, I might call the new object an Event object, but store > it in > > a > > different folder or name it differently so that I know it is NOT a > data > > access component. This object would then do any application > specific> validation, and processing. The tough part with this is > that you have > to > > make a choice where your transactions take place - in the > database, or > in > > CF > > (or whatever language you're using). If you opt for placing the > > transactions in the database (I'd recommend this where > possible), then > the > > call to the stored proc should happen within one of your data access > > components - the business rule component should not be dealing > directly > > with > > the database, that is not it's role. > > > > Conceptually, you might end up with something like this: > > > > EVENT Rules > > - Data Access Components > > - Event data access component > > - Venue data access component > > - Timeslot data access component > > - Specialized data access component (if needed). > > - Business functions > > - Save Event (-which might call individual functions on the > member > > data components) > > > > Not sure if this is entirely clear, but hopefully it get's you > movingin > > the > > right direction... > > > > Shawn > > > > -----Original Message----- > > From: Jim Davis [EMAIL PROTECTED] > > Sent: Thursday, September 18, 2003 1:14 PM > > To: CF-Talk > > Subject: OO modeling Hell > > > > > > Sorry - thismay be semi-off topic (but then again it may be semi-on > > topic - possibly even flat-out on topic!) > > > > I'm working on modeling an existing procedural system (first > built in > CF > > 4) to CFMX and want to implement "correctly" (as possible) in an > OO/CFC > > framework. > > > > I'm doing the static model now and have run into a conceptual > problem.> Hoping for some opinions. > > > > The system is an event planner for a large, single-day festival. > > Stripping it down to the problem domain we have a database model > with> three tables: > > > > 1) "Events": All the events taking place. > > > > 2) "Venue": All the locations that events can take place at. > > > > 3) "TimeSlots": All of the tied begin/end times for events. For > example > > "10:00-14:00", "10:00-11:00", "13:00-15:00", etc > > > > In the DB this works well. "Events" and "TimeSlots" are joined with > > "EventsToTimeSlots" (many to many). You can then query easily based > on > > start-time, end-time, or duration. "EventsToTimeSlots" also > links to > > "Venues". This allows an event to occur at any time and each > time to > be > > located at a distinct venue. > > > > So we may have a dance troupe appearing at 8pm-10pm at the Boston > Ballet > > bulding, then from 11pm-midnight at Boston Common. > > > > When converting this to an object model I naturally began by > considering > > "Event", "Venue" and "TimeSlot" as objects. (Right?) My issue > is how > > to deal with the three-part join. > > > > I have, for example, an array in each TimeSlot object containing a > > references to all the events taking place. I can then loop through > all > > the timeslots and collect all the events taking place at any > time or > of > > a certain duration. Sorting this kind of return may be a > problem, but > > not (I think) big one. > > > > I can also have an array of references in each Venue object to > events> taking place there. Lastly (I'm guessing) can have a two- > dimensional> array of TimeSlot and Venue references in each Event > linking each > > timeslot to a venue. > > > > Is this the best way to do this? > > > > Should I instead some "sub object" that directly represents my join > > table that contains a reference to an Event, TimeSlot and Venue? > Maybe > > called "Schedule" or something? > > > > Or should each TimeSlot object contain a single reference to an > Event> and Venue and just have a lot of duplicate > StartTime/EndTimes? (I > don't > > think I would as it would be more difficult to present the > details of > a > > single event.) > > > > Does this whole "Timeslot" idea just not fit in OO as well as it > doesin > > the relational system? > > > > In the end the model I want should allow each event object to > quickly> get the venue and time for each performance (perhaps that > goes without > > saying) but I also want to be able to easily list "All events at > Venue", > > "All events at TimeSlot" and "All events at StartTime/EndTime". > > > > Thanks in adavance, > > > > Jim Davis > > > > > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm?link=i:4:137614 Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm