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 > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Get the answers you are looking for on the ColdFusion Labs Forum direct from active programmers and developers. http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72&catid=648 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290660 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

