Thanks again Brian, another great reply,

Yes these will defiantly be staying as a cast type, i.e. a image will always
be an image and nothing more so at the moment I think the extended super
class kind of makes good sense for me, taking a base Media object with the
common attributes and extending it to the other sub classes which contain
individual/unique properties. I then keep control over the whole lot with a
service. 

One other thing I am wondering is how to organise my DAO's for this, should
the Media class have its own DAO separate from the sub types? Or should the
DAO's for my sub types deal with the media table as well as their own? I'm
guessing the former, so that in my service saveImage() method it passes the
super inited Image object to both the MediaDAO and the ImageDAO and they can
just suck out the properties they need to persist it. Does that sound like
the best option?

Thanks again mate,

Rob

-----Original Message-----
From: Brian Kotek [mailto:[EMAIL PROTECTED] 
Sent: 09 October 2007 16:30
To: CF-Talk
Subject: Re: CFC Composition and/or Extention

It depends on what you need to do, and how you envision media changing over
time. You can definitely create an abstract Media component that is extended
by concrete components like Image, Video, etc. The only limitation is really
that a component can only inherit from one superclass. Which means you can't
have a media item that is treated as two kinds of media (ie Video is a video
file, and also an Image File (when treated as a bunch of individual
images)). The advantage of composition is that a component can have multiple
objects associated with it, and that those objects can be dynamically added
or removed at runtime. So you gain flexibility with composition, but you add
complexity as well. The advantage of inheritance is that any external code
can treat all subclasses of Media as simply the abstract type Media (this is
polymorphism).

So, if you are pretty sure these things are truly a one-to-one IS-A
relationship (and I think they seem to be, but not knowing more about what
you actually need to do going forward it's impossible to say for sure), and
you want external code to be able to treat all types of media in a similar
way, using the same API, then inheritance sounds like it will work just
fine.


On 10/9/07, Robert Rawlins - Think Blue
<[EMAIL PROTECTED]>
wrote:
>
> Hey Guys,
>
>
>
> I hope you're all well, I've got a challenge when it come to composition
> which I was hoping you could give me a few pointers on,
>
>
>
> Basically I have a scenario in my application which has a
> supertype/subtype
> relationship between a bunch of tables and I'm struggling with how to
> build
> this kind of relationship between my objects. I'm not sure if you've
> worked
> with the supertype idea before, or heard the term, Its actually quite
> simple
> from a database point of view. I'll help clarify it with an example.
>
>
>
> In my application I deal with lots of different types of multimedia, such
> as
> Images, Text Files, Audio, Video, Games and a myriad of other things,
> however my application needs to be able to access these different media
> types from a single location in the database. So I have a single table
> called 'Media' which contains all the common details between different
> media
> files, like ID, Name, Size, DateCreated and such like, and then I have a
> myriad of different tables, like Text, Image, Audio, Video which contain
> all
> the unique information for each different type of message, along with a FK
> which links them back to my 'Media' table.
>
>
>
> Now what I need to be able to do is create a Media object within my
> application, but also have access to that additional information for when
> I
> write it to the database, and likewise when reading out. I'm not sure
> whether this is best solved with some form of composition, or perhaps this
> is where the 'Extend' attribute will come in handy for me? Create the
> media
> object as the Base class and have my other media types Extend it? I really
> don't know.
>
>
>
> What do you think chaps? I hope I haven't confused you too much with my
> babbling question.
>
>
>
> Thanks,
>
>
>
> Rob
>
>
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Download the latest ColdFusion 8 utilities including Report Builder,
plug-ins for Eclipse and Dreamweaver updates.
http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290661
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to