Take this for example...... Say I wanted to cookup a new 'object' of
Type : "ColdFusion Coder".... As Ray suggested, there are a certain
amount of general vanilla parameters, in this case, fname, lname and
age.
So we have 1 class - a "superclass" called human.cfc which looks like
this :
<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..it is adding a coding discipline :
"Language"
<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 (from a standard .cfm page) :
<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 displays fairly simple inheritance with ColdFusion and CFCs -
yes it may not be what you determine as true inheritance, but its
ingeritance nonetheless.
Hope this helps.
Neil
Neil Clark
Team Macromedia
http://www.macromedia.com/go/team
Announcing Macromedia MX!!
-------------------------- http://www.macromedia.com/software/trial/.
______________________________________________________________________
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
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