QUOTE(skyhawk133 @ 14 Aug, 2007 - 01:56 PM)

First, you're on the right track OO in ColdFusion actually makes the language fun and not so mind numbing.
Second, yes, OO in CF is not like OO in other languages... it's pseudo OO.
Third, Yes, things have changed a lot since CF 6 and CF 7.
And finally, I would recommend reading up on Hal Helms, he's does a GREAT job of explaining OO in CF:
http://www.halhelms.comBooks, not sure, I know there are some newer books that focus on OO and CF7 and now maybe even CF8.
kk Hal wrote the book I am learning from...
The point is to pass arguments using two different classes: 5Employee and 5Person (I put the 5 in front to find the files easily in my directory) here is the code
5Person.cfc:
CODE
<cfcomponent>
<cffunction name="new">
<cfargument name="firstName" required="no" type="string" default="null">
<cfargument name="lastName" required="no" type="string" default="null">
<cfargument name="yearBorn" required="no" type="string" default="null">
<cfargument name="subtype" required="no">
<cfset this.firstName = arguments.firstName>
<cfset this.lastName = arguments.lastName>
<cfset this.yearBorn = arguments.yearBorn>
<cfif IsDefined('arguments.subType')>
<cfset child = arguments.subType>
<cfset StructAppend(child,this,'yes')>
<cfreturn child>
</cfif>
</cffunction>
<cffunction name="getName">
<cfreturn this.firstName + ' ' + this.lastName>
</cffunction>
<cffunction name="setName">
<cfargument name="firstName" required="yes" type="string">
<cfargument name="lastName" required="yes" type="string">
<cfset this.firstName = arguments.firstName>
<cfset this.lastName = agruments.lastName>
</cffunction>
</cfcomponent>
5Employee.cfc
CODE
<cfcomponent hint="I am an Employee" extends="com.techspedition.CFCs.5Person">
<cffunction name="new">
<cfargument name="firstName" type="string" required="no">
<cfargument name="lastName" type="string" required="no">
<cfargument name="gender" type="string" required="no">
<cfargument name="dateOfBirth" type="string" required="no">
<cfargument name="department" type="string" required="yes">
<cfargument name="dateOfHire" type="string" required="yes">
<cfargument name="subtype" required="no">
<cfinvoke
component="com.techspedition.CFCs.5Person"
method="new"
subtype="#this#"
returnvariable="aPerson"
firstName="#arguments.firstName#"
lastName="#arguments.lastName#"
gender="#arguments.gender#"
dateOfBirth="#arguments.dateOfBirth#">
<cfset this = aPerson>
<cfset this.employeeID = CreateUUID()>
<cfset this.dateOfHire = arguments.dateOfHire>
<cfset this.department = arguments.department>
<cfif IsDefined('arguments.subType')>
<cfset child = arguments.subType>
<cfset StructAppend(child,this,'yes')>
<cfreturn child>
</cfif>
</cffunction>
</cfcomponent>
5testEmployee.cfm
CODE
<cfset maxie = CreateObject('component', '5Employee')>
<cfset maxie.new('Maxie', 'Mumm', 'Female', '5/31/1958', 'Accounting', '12/25/1999')>
<cfdump var="#maxie#">
Here is the output:
DEPARTMENT Accounting
YEARBORN null
FIRSTNAME Maxie
LASTNAME Mumm
EMPLOYEEID 6A8A1E0E-C6C9-9A59-B1D1970F03202050
DATEOFHIRE 12/25/1999
gender and dateOfBirth disappear into oblivion. Those to variables are only defined in 5Employee.cfc and they are lost in the dump....well his output in the book shows that they make it along with everything else...well I had a hunch and I changed the code in 5Employee.cfc:
...
CODE
<cfinvoke
component="com.techspedition.CFCs.5Person"
method="new"
subtype="#this#"
returnvariable="aPerson"
firstName="#arguments.firstName#"
lastName="#arguments.lastName#">
<cfset this = aPerson>
<cfset this.employeeID = CreateUUID()>
<cfset this.gender = arguments.gender>
<cfset this.dateOfBirth = arguments.dateOfBirth>
<cfset this.dateOfHire = arguments.dateOfHire>
<cfset this.department = arguments.department>
...
this worked. OK WHY is my question, my way makes more sense because essentially we are invoking the 'super class' 5Person.cfc and those variables are not included in 5Person, they are in 5Employee...but in the book, the way he did it, he included gender and dateOfBirth in the invoke statement and it worked...why?