I'm still a bit of a noob to this myself, but my .02 would be this: ExampleA is "coupled" to com.useful.Thingy in that it has knowledge of com.useful.Thingy's doSomething() member.
ExampleB really isn't much different. ExampleC has two dependencies - it relies on com.use.ThingyHolder having a getThingy() method, and on the result of getThingy() have a doSomething() method. I think one of the OO principles I've seen that can be applied here is "speak only to your closest friends." Taking that approach, I'd call ExampleC the most heavily coupled of the bunch. One thing to take into consideration is coding to interfaces, not implementations - instead of requiring a com.useful.Thingy, require a com.useful.BaseType that Thingy implements/extends, where all types extending BaseType have a doSomething() method. Maybe we'll eventually have some sort of abstract capability in CFCs, but for now this probably means keeping track of things without real enforcement or using inheritance. -Joe On Wed, 19 Jan 2005 09:01:04 -0500, Patrick McElhaney <[EMAIL PROTECTED]> wrote: > ExampleC had a minor "bug." It's fixed below. > > > <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.thirdParty> > > </cffunction> > > > > <cffunction name="doSomething"> > > <cfreturn variables.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] > -- For Tabs, Trees, and more, use the jComponents: http://clearsoftware.net/client/jComponents.cfm ---------------------------------------------------------- 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]
