I won't bother to get back into the discussion about the use of the "THIS"
scope to hold instance data other than to say you shouldn't -- but, that's
not your question.

I'm curious what benefit you are deriving from having this abstraction.  I
can understand some kind of abstract access to capture the benefit of your
error handling, but why have that be the end-user method?  Perhaps it would
be better for your extending components to expose a more intuitive API and
use your getRecordSet method internally -- then your documentation for your
CFCs will make a lot more sense.  As it stands, it seems the end user needs
to know a fair amount about the implementation of how you are doing things.

But, that said, if you want to do what you are doing, one option would be to
actually have a getRecordSet method in your extending component that calls
super.getRecordSet() -- that way you can have the CFARGUMENT tags relevant
to the particular implementation of a given component, but then use your
underlying machinery.  You'd could then call the onGetRecordSet method like
this:

onGetRecordSet(argumentCollection=arguments);

The onGetRecordSet implementation would then need to expect the same
arguments as the getRecordSet method in the extending component.  So, the
end user might do:

tablespecific.getRecordSet(myCode,myType);

tablespecific would then say something like:

<cffunction name="getRecordSet">
<cfargument name="myCode">
<cfargument name="myType">
<cfset super.getRecordSet(argumentCollection=arguments)>
</cffunction>

Again, I'm not sure that really makes any sense since the notion of
getRecordSet says too much about implementation and not enough about
interface, but that would be one way to pull it off.


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of
Hinkle, Roy
Sent: Monday, October 06, 2003 10:49 AM
To: '[EMAIL PROTECTED]'
Subject: [CFCDev] CFC base class with arbitray arguments calling a virtual
function


Greetings,
I have a base class for our data access which defines a "GetRecordset"
method. This method can have any number of arguments passed to it. The
GetRecordset is in the base class and it calls a pseudo-virtual method to
get the table specific SQL.
I need to pass the arguments from GetRecordset to the virtual function so
the developer creating the table specific class can parse the arguments for
the dynamic SQL.
Note: I left the <CFARGUMENT tags out of both functions on purpose because i
am unsure what to put.
Any ideas?


Here's a sample of the code:
<cfcomponent name="basecomponent">
        <cfset THIS.errormsg = "">
        <cfset THIS.dsn = "">
        <cffunction name="Init" returntype="boolean">
                <cfargument name="dsn" type="string" required="false">
                <cfset retval = True>
                <cftry>
                        <!--- set datasource --->
                        <cfif THIS.dsn IS "">
                                <cfif isdefined("ARGUMENTS.dsn")>
                                        <cfset THIS.dsn = "#ARGUMENTS.dsn#">
                                </cfif>
                        </cfif>
                        <cfcatch>
                                <cfscript>
                                        SaveErrorInfo(CFCATCH);
                                </cfscript>
                                <cfset retval = False>
                        </cfcatch>
                </cftry>
                <cfreturn retval>
        </cffunction>
        <cffunction name="GetRecordset" displayname="Get Recordset as query
variable">
                <cfif THIS.dsn IS NOT "">
                        <cftry>
                                <cfquery datasource="#THIS.dsn#"
name="qryGetRecordset">
                                        #OnGetRecordset()#
                                </cfquery>
                                <cfcatch type="database">
                                        <cfscript>
                                                SaveErrorInfo(CFCATCH);
                                        </cfscript>
                                </cfcatch>
                        </cftry>
                </cfif>

                <cfreturn qryGetRecordset>
        </cffunction>
        <!--- virtual method --->
        <cffunction name="OnGetRecordset">
        </cffunction>
        <cffunction name="SaveErrorInfo" access="private">
                <cfargument name="catchobject" type="any" required="true">
                <cfset THIS.errormsg = "CFCATCH.message=" &
ARGUMENTS.catchobject.message
                        & "<br>cfcatch.NativeErrorCode=" &
ARGUMENTS.catchobject.NativeErrorCode
                        & "<br>cfcatch.SQLState=" &
ARGUMENTS.catchobject.SQLState & "<br>" & ARGUMENTS.catchobject.detail>
        </cffunction>
</cfcomponent>
<cfcomponent extends="basecomponent" name="tablespecific">
        <cffunction name="OnGetRecordset">
                SELECT DELIVERY_CODE, DELIVERY_TYPE FROM
FITSOWNER.DELIVERY_DATA_CODES
                <cfif isdefined("ARGUMENTS.code")>
                        where DELIVERY_CODE = '#ARGUMENTS.code#'
                <cfelseif isdefined("ARGUMENTS.type")>
                        where DELIVERY_TYPE = '#ARGUMENTS.type#'
                </cfif>
        </cffunction>
</cfcomponent>



Roy Hinkle
Advanced Information Engineering Systems (formerly Veridian)
301.863.4352 (phone)
301.863.4443 (fax)
[EMAIL PROTECTED]

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to