On 10/20/07, Alan Livie <[EMAIL PROTECTED]> wrote: > > > I have a service CFC that is composed of various other CFC's in the > same package (directory). > > I have also composed it with CFC's from other packages directly > (Gateway CFCs for query returns etc) > > My question is: > > Should I compose xService.cfc with yObj.cfc directly or yService.cfc > (which is composed of a yObj) > > ie should xService get a yObj directly or should it be composed of > yService and let yService be composed of yObj ?
In my opinion, the approach of passing the service objects into the other objects is much better. So I would definitly compose yService into xService and only go through the service object API to make anything happen. And this doesn't just apply when service objects need to call other services...it applies to just about any kind of object. For example, if I have an InventoryService and a ShoppingCart object, and I want to be able to check in my ShoppingCart whether a product is in stock, I would compose the InventoryService into the ShoppingCart. I have opted for the simpler solution of just getting the yGateway > object I need composed in xService. My reason being if yService ends > up being composed of many other objects I will have all these > unnecessary objects I don't need in my xService The flaw in your logic is that when you compose an object, you are creating a reference to that object. You are not creating a copy of it. So if you compose yService into xService, it makes no difference at all how many objects yService has composed into it. In fact, that's the whole point of doing it that way: yService might in turn need to call 1 other object, or 10 other objects, to do its work. But xService never knows. Hope this makes sense :-) > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CFCDev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfcdev?hl=en -~----------~----~----~----~------~----~------~--~---
