On Wed, 19 Jan 2005 06:16:57 -0800, Joe Rinehart <[EMAIL PROTECTED]> wrote:
> ExampleA is "coupled" to com.useful.Thingy in that it has knowledge of
> com.useful.Thingy's doSomething() member.

A needs to know that there is a class called Thingy and that it has a
method called doSomething().

> ExampleB really isn't much different.

Correct.

> ExampleC has two dependencies - it relies on com.use.ThingyHolder
> having a getThingy() method, and on the result of getThingy() have a
> doSomething() method.

But C is more loosely coupled to Thingy. C is dependent on
ThingyHolder but not on the Thingy itself. Whatever
ThingyHolder.getThing() returns must have a doSomething() method but
it could be absolutely any type of object.

C is an example of a factory - C depends on the factory to provide the
actual object to operate on.

> 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.

Well, CF doesn't have interfaces so you need to be a little careful
with that analogy.

Inheritance is just about the tightest possible coupling you can have
between two classes, which is a good reason to avoid inheritance in
favor of composition (ExampleA uses composition because it contains a
reference to Thingy, ExampleC uses composition for the 'registry').
-- 
Sean A Corfield -- http://www.corfield.org/
Team Fusebox -- http://www.fusebox.org/
Breeze Me! -- http://www.corfield.org/breezeme
Got Gmail? -- I have 5 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' 
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]

Reply via email to