On Sat, 26 Mar 2005 00:37:25 -0000, jamie lawrence <[EMAIL PROTECTED]> wrote: > i have a vehicle.cfc, which has a composite dao as one of its properties, > the dao itself has a composite database cfc
Normally a business object would not know about its DAO so it wouldn't be structured like this. DAOs are intended to separate the persistence from the BO (business object). > my question is, how do i reference the properties of the database cfc, and > the methods of the dao, from within the vehicle cfc it self, and from > outside of the cfc from the controller Well, that's why you don't normally do it that way... > Also, how do i reference the instance scope of the vehicle cfc, from > within the vehicle dao. You would need to pass it into the DAO method calls - something that a controller normally does: snapshot = myCar.getInstanceData(); carStore.update(snapshot); > Does a composition like this all share the same variables (instance) > scope? Not in the way I think you mean. Each object has its own variables scope - they are distinct. However, the lifetime of an object instance matches the scope in which it is stored (so they share lifetimes but not visibility). > I realise that the above method also breaks encapsulation, so would i pass > in objects to the init method of the vehicle cfc. Would this pass a > reference to an object outside of vehicle cfc or would the whole object be > passed into the vehicle cfc? CFC instances are passed by reference. > Sorry to ask so many (probably simple) questions, i am reading a good oo > book for php and trying to apply the principles to cf, favour composition > over inheritance, Yes, composition is the more appropriate solution in nearly all cases. But you need to think carefully about the relationships between your objects. -- Sean A Corfield -- http://corfield.org/ Team Fusebox -- http://fusebox.org/ Got Gmail? -- I have 50, yes 50, invites to give away! "If you're not annoying somebody, you're not really alive." -- Margaret Atwood ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
