Of course if I add the following to human.cfc I will break everything
even though I would be following a proper OO technique. As I am sure you
know, you are not supposed to allow public access to properties.

<cfproperty name="age" type="numeric" access="private">
<cffunction name="getAge" returntype="numeric" access="public">
        <cfreturn this.age>
</cffunction>
<cffunction name="setAge" access="public">
        <cfargument name="age" type="numeric">
        <cfset this.age = age>
</cffunction>

-Matt

> -----Original Message-----
> From: Neil Clark - =TMM= [mailto:[EMAIL PROTECTED]]
> Sent: Monday, April 29, 2002 3:55 PM
> To: CF-Talk
> Subject: RE: I like CFMX
> 
> That is the definition yep :-)  but take this for example......  Say I
> wanted to cookup a new 'object' of a ColdFusion Coder.... of course
the
> coder could be a human yes?
> 
> So we have 1 class - a superclass called human.cfc which looks like :
> 
> <cfcomponent name="human">
> 
> <cffunction name="createhuman" returntype="struct" access="package">
>       <cfargument name="fname" default="" type="string">
>       <cfargument name="lname" default="" type="string">
>       <cfargument name="age" default="-1" type="numeric">
>               <cfscript>
>                       this.fname = arguments.fname;
>                       this.lname = arguments.lname;
>                       this.age = arguments.age;
>               </cfscript>
> 
>       <cfreturn this>
> </cffunction>
> 
> </cfcomponent>
> 
> We also have a CFC named coder .cfc which is extending/inheriting the
> human.cfc method & properties..
> 
> <cfcomponent name="coder" extends="human">
> 
> <cffunction name="create" returntype="struct">
>       <cfargument name="language" default="" type="string">
>       <cfscript>
>       createhuman(argumentCollection=duplicate(arguments));
>       </cfscript>
>       <cfset this.language = arguments.language>
>       <cfreturn this>
> </cffunction>
> 
> </cfcomponent>
> 
> we can now call this <cfcomponent name="coder" extends="human">
> 
> <cffunction name="create" returntype="struct">
>       <cfargument name="language" default="" type="string">
>       <cfscript>
>       createhuman(argumentCollection=duplicate(arguments));
>       </cfscript>
>       <cfset this.language = arguments.language>
>       <cfreturn this>
> </cffunction>
> 
> </cfcomponent>
> 
> We can either now, call human.cfc to create a simple human with
default
> params, or we can call the coder.cfc to add instance variables to
> human.cfc thus :
> 
> <cfset stArgs = structNew()>
> <cfset stArgs.fname = "Neil">
> <cfset stArgs.lname = "Clark">
> <cfset stArgs.age = 29>
> <cfset stArgs.language = "ColdFusion">
> 
> <cfinvoke component="com.macromedia.coder" method="create"
> argumentcollection="#stArgs#" returnvariable="coder" />
> 
> <cfoutput>#coder.lname#, #coder.fname#, #coder.age#</cfoutput>
> 
> This is inheritance in the ColdFusion CFC vain - yes it may not be
what
> you determine as true inheritance, but its ingeritance nonetheless.
> 
> Though I concuse with you of the dict definition, but I still think
> CFC's can still be OOP.
> 
> Neil
> 
> 
> 
> Neil Clark
> Team Macromedia
> http://www.macromedia.com/go/team
> 
> Announcing Macromedia MX!!
> --------------------------
> http://www.macromedia.com/software/trial/.
> 
> 
> 
______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to