On Thursday, Jan 30, 2003, at 21:58 US/Pacific, Andy Ousterhout wrote:
> OK, I am hooked after only a few hours on CFC's.  This is so much 
> easier to
> code that what I was trying to do with modules & includes in 5.0....

:)

> For the sake of discussion, lets also say I have another component 
> called
> Invoice that needs two Person objects, one for Ordering Person and 
> another
> for Ship To person.  I can't just use extends because that creates a 
> single
> person instance.   How do I code this?

"extends" represents an "is-a" relationship:

        car "is-a" vehicle

so

        <!--- car.cfc --->
        <cfcomponent extends="vehicle">
                ...
        </cfcomponent>

is a reasonable model.

"has-a" is modeled by 'containment' - having data members:

        Invoice "has-a" Ordering Person
        Invoice "has-a" ShipTo Person

so

        <!--- invoice.cfc --->
        <cfcomponent>
                <cffunction name="create">
                        <cfargument name="shipto" type="person">
                        <cfargument name="orderer" type="person">
                        <cfset this.shipto = arguments.shipto>
                        <cfset this.orderer = arguments.orderer>
                </cffunction>
        </cfcomponent>

Hope that helps?

Sean A Corfield -- http://www.corfield.org/blog/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to