RE: CFC Composition and/or Extention
Exactly what I meant, but put much more elegantly! Rich Kroll > -Original Message- > From: Brian Kotek [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 10, 2007 11:53 AM > To: CF-Talk > Subject: Re: CFC Composition and/or Extention > > I would do something similar as well (though just make sure to purge it > back > out if something goes wrong in the rest of the transaction, since you'll > probably be returning the object back to the view for use in displaying > the > data they entered into the form and you don't want it to have the wrong > ID). > Which means, of course, make sure this whole process is wrapped in a > cftransaction block so that it succeeds or fails as a single unit. The > service layer is often a good place for transaction logic since it usually > applies to multiple domain objects at once. ~| Check out the new features and enhancements in the latest product release - download the "What's New PDF" now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290781 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CFC Composition and/or Extention
I would do something similar as well (though just make sure to purge it back out if something goes wrong in the rest of the transaction, since you'll probably be returning the object back to the view for use in displaying the data they entered into the form and you don't want it to have the wrong ID). Which means, of course, make sure this whole process is wrapped in a cftransaction block so that it succeeds or fails as a single unit. The service layer is often a good place for transaction logic since it usually applies to multiple domain objects at once. On 10/10/07, Rich <[EMAIL PROTECTED]> wrote: > > > Now I could do > > this in my super classes create() method, by having it return the ID for > > the > > entry it just created, however this does feel a little unusual, mainly > > because I'm not used to working with super objects, is that the correct > > way > > At the end of SUPER.create( ARGUMENTS.SubObject ) you can have the parent > DAO call ARGUMENTS.SubObject.setID( newlyCreatedId ) which will make it > available in the child. Make sure you make this a transaction so you > don't > end up having orphaned IDs in the parent table. > > HTH, > Rich Kroll > > > ~| Enterprise web applications, build robust, secure scalable apps today - Try it now ColdFusion Today ColdFusion 8 beta - Build next generation apps Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290771 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: CFC Composition and/or Extention
> Now I could do > this in my super classes create() method, by having it return the ID for > the > entry it just created, however this does feel a little unusual, mainly > because I'm not used to working with super objects, is that the correct > way At the end of SUPER.create( ARGUMENTS.SubObject ) you can have the parent DAO call ARGUMENTS.SubObject.setID( newlyCreatedId ) which will make it available in the child. Make sure you make this a transaction so you don't end up having orphaned IDs in the parent table. HTH, Rich Kroll ~| 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:290741 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFC Composition and/or Extention
On Wednesday 10 Oct 2007, [EMAIL PROTECTED] wrote: > Now the problem with this arises in the fact when I create an entry in my > sub classes table, I need to know the ID of the freshly made entry in my > super classes table, so as to establish their relationship. Now I could do > this in my super classes create() method, by having it return the ID for > the entry it just created, It'd be the my first take at a solution. -- Tom Chiverton Helping to seamlessly morph industry-wide market-growth on: http://thefalken.livejournal.com This email is sent for and on behalf of Halliwells LLP. Halliwells LLP is a limited liability partnership registered in England and Wales under registered number OC307980 whose registered office address is at St James's Court Brown Street Manchester M2 2JF. A list of members is available for inspection at the registered office. Any reference to a partner in relation to Halliwells LLP means a member of Halliwells LLP. Regulated by The Solicitors Regulation Authority. CONFIDENTIALITY This email is intended only for the use of the addressee named above and may be confidential or legally privileged. If you are not the addressee you must not read it and must not use any information contained in nor copy it nor inform any person other than Halliwells LLP or the addressee of its existence or contents. If you have received this email in error please delete it and notify Halliwells LLP IT Department on 0870 365 8008. For more information about Halliwells LLP visit www.halliwells.com. ~| ColdFusion 8 - Build next generation apps today, with easy PDF and Ajax features - download now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290728 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: CFC Composition and/or Extention
Brian or anyone else, I've come to a bit of a stumbling block when working on this extended DAO model which has gotten me a little confused. It comes when trying to figure out my create() method inside my sub class DAO. The idea we talked about below would be to pass in the object which is to be persisted into the create() method of my sub class object, and then at the top of the method run SUPER.create(ARGUMENTS.SubObject) before running my standard create query. Now the problem with this arises in the fact when I create an entry in my sub classes table, I need to know the ID of the freshly made entry in my super classes table, so as to establish their relationship. Now I could do this in my super classes create() method, by having it return the ID for the entry it just created, however this does feel a little unusual, mainly because I'm not used to working with super objects, is that the correct way to handle it or is there a better way which I can't see? Thanks again chaps, R -Original Message- From: Robert Rawlins - Think Blue [mailto:[EMAIL PROTECTED] Sent: 09 October 2007 21:50 To: CF-Talk Subject: RE: CFC Composition and/or Extention Oooh! Nice concept Brian, I hadn't thought about extending DAO's like that...I like it a lot. I now knight thee, Brian The Brain Kotek Thanks mate, Rob -Original Message- From: Brian Kotek [mailto:[EMAIL PROTECTED] Sent: 09 October 2007 18:25 To: CF-Talk Subject: Re: CFC Composition and/or Extention I would follow the same subtype/supertype idiom in your DAO objects. Have an abstract MediaDAO which handles all the database interaction for the Media table, and have concrete subtypes for each type of Media (VideoDAO, ImageDAO, etc.) so that they can handle their own type-specific data. I would have the concrete DAOs first run something like super.insert(data) so that the superclass will handle whatever has to happen with the Media table, and then they can go on doing their own type-specific database interactions with their own tables. On 10/9/07, Robert Rawlins - Think Blue <[EMAIL PROTECTED]> wrote: > > 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 > > ~| Check out the new features and enhancements in the latest product release - download the "What's New PDF" now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290723 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: CFC Composition and/or Extention
Oooh! Nice concept Brian, I hadn't thought about extending DAO's like that...I like it a lot. I now knight thee, Brian The Brain Kotek Thanks mate, Rob -Original Message- From: Brian Kotek [mailto:[EMAIL PROTECTED] Sent: 09 October 2007 18:25 To: CF-Talk Subject: Re: CFC Composition and/or Extention I would follow the same subtype/supertype idiom in your DAO objects. Have an abstract MediaDAO which handles all the database interaction for the Media table, and have concrete subtypes for each type of Media (VideoDAO, ImageDAO, etc.) so that they can handle their own type-specific data. I would have the concrete DAOs first run something like super.insert(data) so that the superclass will handle whatever has to happen with the Media table, and then they can go on doing their own type-specific database interactions with their own tables. On 10/9/07, Robert Rawlins - Think Blue <[EMAIL PROTECTED]> wrote: > > 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 > > ~| Enterprise web applications, build robust, secure scalable apps today - Try it now ColdFusion Today ColdFusion 8 beta - Build next generation apps Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290694 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFC Composition and/or Extention
I would follow the same subtype/supertype idiom in your DAO objects. Have an abstract MediaDAO which handles all the database interaction for the Media table, and have concrete subtypes for each type of Media (VideoDAO, ImageDAO, etc.) so that they can handle their own type-specific data. I would have the concrete DAOs first run something like super.insert(data) so that the superclass will handle whatever has to happen with the Media table, and then they can go on doing their own type-specific database interactions with their own tables. On 10/9/07, Robert Rawlins - Think Blue <[EMAIL PROTECTED]> wrote: > > 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 > > ~| Get involved in the latest ColdFusion discussions, product development sharing, and articles on the Adobe Labs wiki. http://labs/adobe.com/wiki/index.php/ColdFusion_8 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290676 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: CFC Composition and/or Extention
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
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 > > > > ~| 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
CFC Composition and/or Extention
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 ~| Create robust enterprise, web RIAs. Upgrade to ColdFusion 8 and integrate with Adobe Flex http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290643 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4