Thanks Neil...I'm certainly no stranger to basic OO concepts...it's the
first few real world examples I've been struggling with...and I think that's
because of the complexities I've been trying to deal with...well I guess
they always feel *complex* the first few times...feels as though I could
inherit properties in either direction. I know that may sound strange but
here's an example:

I have a reporting "object" which has generic functionalities like
extracting the data in different formats i.e. HTML, XML, CSV.

Then there's 3 different types of reports which I guess would each extend
the reporting object. The reports reflect financial transaction data.

Here's the tricky part (for me). Each of these three reports could be
applied to 4 different types of transactions...One kind is an authorization
another is a credit etc..

So...I'm torn between extending each report TYPE to have a sub-classes of
auth,settle,credit and failed OR having AUTH,SETTLE,CREDIT and FAILED
objects which are then extended based on the type of report it is...

Report Object -> Report Type -> Transaction Type

Or

Report Object -> Transaction Type -> Report Type

Going forward I'm sure there will be additional report types but very rarely
would there be additional transaction types added to the equation.

Any comments, suggestions?

Thanks all,

Stace


-----Original Message-----
From: Neil Clark - =TMM= [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, June 11, 2002 9:34 AM
To: CF-Talk
Subject: RE: Examples of Inheritance?

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

Reply via email to