In this case then...

A specific event object would have a property for venue, and another for
time slot.  These properties would be of type Venue and type Timeslot
respectively (that is, Event.Time would be a timeslot object based on the
timeslot class, and Event.Venue would be a venue object based on the venue
class). Try not to use the same name for both your properties and your class
definitions, otherwise you might get errors, and cause confusion.

When you look at a venue object, it doesn't really have a direct correlation
to a specific event, or time, so will not have properties for these
elements.  Same with a Timeslot object - there is no real direct correlation
between a venue and an event, so no properties for these here either.  Yes,
a timeslot can be associated with a venue and/or an event, but the timeslot
iteself doesn't really care.

So, I'd make a generic timeslot object (with start time, end time, and any
needed methods), a generic venue object (with location and any needed
methods), and then an event object with properites for the event details
including timeslot and venue.

When it comes to listing items by timeslots or venues, this would be a
specialized query of your data.  Perhaps the Timeslot object could have a
method "PrintSchedule" that will do whatever is needed to create a schedule,
but scheduling is a time related function so logically should be with the
Timeslot object.  On the other hand, a Venue might also have a
"PrintSchedule" method that would list only the events for that particular
venue.  The implementation details are, of course, best left to you.  But I
post some possibilities here in hopes it might help you determine where
things should go.

I should make a disclaimer though - I don't know the specific details of
your requirements, so my examples might be completely off...

HTH.

Shawn

-----Original Message-----
From: Jim Davis [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 18, 2003 2:36 PM
To: CF-Talk
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 taking
place 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 objects
in 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 [mailto:[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 moving
in
> the
> right direction...
> 
> Shawn
> 
> -----Original Message-----
> From: Jim Davis [mailto:[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 does
in
> 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:137611
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

Reply via email to