Here's one example:

<cfcomponet hint="Car">
   <cfset variables.engine = CreateObject('component', 'Engine') />

   <cffunction name="getEngine" returntype="Engine">
      <cfreturn variables.engine />
   </cffunction>
</cfcomponent>

The Car "has a" Engine component. 

Hal Helms
See halhelms.com for classes in...
Java for ColdFusion Programmers
Fusebox 4
Mach-II
OO Applications with CFCs

-----Original Message-----
From: Ian Skinner [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 04, 2003 1:39 PM
To: CF-Talk
Subject: RE: CFC/Object Best Practice


Thanks, I've got a pretty good handle on inheritance (a Porsche IS A
car) ... using cfcomponent extends.  What I'm looking for is how one
might code other types of relationships such as (a car HAS A engine).
What might the cfc code look like to accomplish this?

Thanks for the link, looks like a good one, I'm going to read through it
now.

--------------
Ian Skinner
Web Programmer
BloodSource
Sacramento, CA


-----Original Message-----
From: Joe Eugene [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 04, 2003 9:17 AM
To: CF-Talk
Subject: Re: CFC/Object Best Practice


> And how would this look in the code of a CFC?

<cfcomponent extends="MyParentComponent">

You use the the "extends" to Inherit Instance variables from your parent
CFC to Your Sub CFC.

Your might want to read
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/buildi52.htm

> (designing them is another story).

To Design Blue Prints for Objects Or Classes (OOD), you need to have a
good understanding of your application model.

Joe Eugene


----- Original Message ----- 
From: "Ian Skinner" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, September 04, 2003 11:14 AM
Subject: RE: CFC/Object Best Practice


> >> practice to code this relationship in an CFC.  How would the car 
> >> code
> send
> >> and receive messages to the engine code?
>
> >Objects talk to each other by invoking their instance methods.
>
> And how would this look in the code of a CFC?
>
> >I think you might be trying real hard to apply inheritance above (Car

> >- Engine), to me this is more of abstraction - divide and conquer... 
> >not really inheritance.
>
> Exactly, I have a pretty good idea of how to code and use inheritance 
> (designing them is another story).  My example was supposed to be an
example
> of relationship that WAS NOT inheritance, and how would one code cfc's

> for this relationship?
>
> --------------
> Ian Skinner
> Web Programmer
> BloodSource
> Sacramento, CA
>
>
> -----Original Message-----
> From: Joe Eugene [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 04, 2003 8:01 AM
> To: CF-Talk
> Subject: Re: CFC/Object Best Practice
>
>
> > practice to code this relationship in an CFC.  How would the car 
> > code
send
> > and receive messages to the engine code?
>
> Objects talk to each other by invoking their instance methods.
>
> > themselves).  Anyway, using the ever present car object example.  
> > You
have
> a
> > car class/object that contains an engine class/object
>
> I think you might be trying real hard to apply inheritance above(Car -

> Engine), to me this is more of abstraction - divide and conquer... not

> really inheritance.
>
> An example of Inheritance would be some like
>
> Dog
>  - Hunting dog
>  - Pet dog
>
> Both Hunting dog and Pet dog inherit the properties of DOG...(ie all 
> Dogs have 4 legs, 2 eyes, nose etc) while Hunting dog itself has the 
> extensive properties/features of a
Hunting
> Dog(vigilant ...)
>
> Joe Eugene
>
> ----- Original Message -----
> From: "Ian Skinner" <[EMAIL PROTECTED]>
> To: "CF-Talk" <[EMAIL PROTECTED]>
> Sent: Thursday, September 04, 2003 10:42 AM
> Subject: CFC/Object Best Practice
>
>
> > Ok, I think I have a pretty good handle on how to code inheritance 
> > with CFC's, but I'm not so sure how you do aggregation and/or 
> > composition
> (still
> > learning the concepts of Object orientated programming as well as 
> > cfc's themselves).  Anyway, using the ever present car object 
> > example.  You
have
> a
> > car class/object that contains an engine class/object.  What is the 
> > best practice to code this relationship in an CFC.  How would the 
> > car code
send
> > and receive messages to the engine code?
> >
> > Thanks
> >
> > --------------
> > Ian Skinner
> > Web Programmer
> > BloodSource
> > Sacramento, CA
> >
> >
>
> 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com

Reply via email to