I'm a little rusty here, but here goes:
I believe the correct term for Example B is a method dependency, that is, one method of your class knows Thingy. This would be represented in UML with a dashed line from ExampleB.doSomething() to Thingy.
ExampleA has a class dependency, because the entire class maintains a reference.to Thingy. This would be represented in UML as a solid line from ExampleA to Thingy.
ExampleC has a method dependency from doSomething to Thingy, and a class dependency on ThingyHolder. Depending upon what ThingyHolder and Thingy are, what might argue that ExampleA or ExampleC are more "OO."
That said, if all ExampleA.doSomething() does is directly return a call to Thingy, why not ask Thingy directly, instead of asking ExampleA to ask Thingy.
Method dependencies are generally less bad than class dependencies.
HTH,
Chris
On Jan 19, 2005, at 5:05 AM, Patrick McElhaney wrote:
Lately people on this list have thrown around the word "coupling" a lot. I thought I had an understanding of what coupling is but now I'm not so sure.
Can someone tell me which of these three CFCs is coupled to Thingy? Is one more coupled than another?
<cfcomponent name="ExampleA"> <cffunction name="init"> <cfargument name="thingy" type="com.useful.Thingy"> <cfset variables.thingy= arguments.thingy> </cffunction> <cffunction name="doSomething"> <cfreturn variables.thingy.doSomething()> </cffunction> </cfcomponent>
<cfcomponent name="ExampleB"> <cffunction name="doSomething"> <cfargument name="thingy" type="com.useful.Thingy"> <cfreturn arguments.thingy.doSomething()> </cffunction> </cfcomponent>
<cfcomponent name="ExampleC"> <cffunction name="init"> <cfargument name="thirdParty" type="com.useful.ThingyHolder"> <cfset variables.thirdParty= arguments.registry> </cffunction>
<cffunction name="doSomething"> <cfreturn thirdParty.getThingy().doSomething()> </cffunction> </cfcomponent>
-- Patrick McElhaney 704.560.9117 http://pmcelhaney.blogspot.com ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
--
*************************************** Chris Dempsey Director, Information Services UCSB Graduate Division Abutebaris modo subjunctivo denuo
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
