As usual, Matt Quack is spot on. I just wanted to add that extending is an "IS-A" relationship. If your service extended a DAO, you would say your service is a DAO. That's why Matt said they are very different objects. Is your service an object that talks directly to a database? No, it probably should not be. Going the other direction is also wrong, by saying your DAO is a Service. Is your DAO an object that takes in requests from your controller or other areas of your application that are making requests on your model? Probably not.
Instead, injecting components, as you are doing, is called composition. This is a "HAS-A" relationship. Should your service have a DAO? Yes, probably. Now, if you wanted to remove all the plumbing of initializing and injecting your DAO into your Service, you can use a bean factory like ColdSpring or DI/1. nathan strutz [www.dopefly.com] [hi.im/nathanstrutz] On Tue, Jan 29, 2013 at 7:42 AM, Matt Quackenbush <[email protected]>wrote: > > A service object is a service object and a DAO is a DAO. They are two very > different objects that serve two very different purposes in an application. > "Prefer composition over inheritance." In other words, keep doing what > you're doing there (injecting the DAO). > On Jan 29, 2013 8:37 AM, "Eric Cobb" <[email protected]> wrote: > > > > > I have a service CFC that calls my dao CFC a lot. Currently, I just pass > > in an object of the dao to the service's init() method and save it to the > > variables scope to be used throughout the service. But, I'm wondering > if I > > would be better off having my service CFCs extend their dao's instead. > > > > Thoughts? Are there any benefits to extending a CFC instead of just > > passing it in as an object, or is passing an object better? > > > > Thanks, > > > > Eric > > http://www.cfgears.com > > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:354106 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

