Yes Peter, purely syntactic sugar. However, I think that syntax is
just as important to you as it is to me :)

Just so that we are all on the same page, here is the methods from
Hal's baseComponent.cfc class:

        <cffunction name="set" access="public" output="false">
                <cfargument name="propertyName" required="true" />
                <cfargument name="propertyValue" required="true" />
                <cfif StructKeyExists(this, 'set' & arguments.propertyName)>
                        <cfinvoke component="#this#" method="set#PropertyName#">
                                <cfinvokeargument name="propertyName" 
value="#arguments.propertyName#" />
                                <cfinvokeargument name="propertyValue" 
value="#arguments.propertyValue#" />
                        </cfinvoke>
                        <cfreturn />
                </cfif>
                <cfset variables.instance[arguments.propertyName] = 
arguments.propertyValue />
        </cffunction>
        
        <cffunction name="get" access="public" output="false" hint="Throws
exception if variables.instance[propertyName] not found">
                <cfargument name="propertyName" required="true" />
                <cfset var results = variables.instance[arguments.propertyName] 
/>
                <cfif StructKeyExists(this, 'get' & arguments.propertyName)>
                        <cfinvoke component="#this#" 
method="get#arguments.propertyName#"
returnvariable="results" />
                </cfif>
                <cfreturn results />
        </cffunction>

As you can see, the set method checks to see if
set#arguments.propertyName# exists and if it does it invokes it. Is
this checking if a method named set#arguments.propertyName# exists in
the child method or in the base component? The reference to this has
me thinking it could be the latter (and then I searched to find out,
got more confused, posted this thread, and you know the rest), but
what do I know?

Thanks,
Aaron

On 5/4/07, Peter Bell <[EMAIL PROTECTED]> wrote:
Hi Aaron,

If you're talking about a method called getProperty(), of course you could
rename your generic getter to getProperty() and that would work. I'm
assuming you're more talking about a get#PropertyName#() solution so you
could call getFirstName() an getLastName() without actually having to write
such methods.

To my knowledge there is no way you can implement this in ColdFusion as you
are calling methods that don't exist. To be able to do this you would need
some kind of missing method handler capability in CF which would then
effectively take care of this problem.

Only thing I'd say is that to me this is more syntactic sugar than anything
else - the difference betweeen getUserName() and get("UserName") is to me
fairly subtle.

Best Wishes,
Peter


You are subscribed to cfcdev. To unsubscribe, please follow the instructions at 
http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

An archive of the CFCDev list is available at 
www.mail-archive.com/cfcdev@cfczone.org

Reply via email to