I use this format for get/set property methods.  Every time I do ColdFusion development, I try to think of ways to code like I would (conceptually) in C#, my other main language.  That way I don't need to modify my brain patterns too much when switching back and forth.  Plus it cuts your development time in half when creating property methods.

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gareth Edwards
Sent: Wednesday, March 30, 2005 10:36 PM
To: [email protected]
Subject: RE: [CFCDev] cfc check

Something that I've seen someone do was use a bit of trickery and allow the same function that gets the variable to set it, I thought it was quite neat.
 
Something like
 
<cffunction name="setServer" access="private" returntype="string">
      <cfargument name="newValue" required="false" type="string"> 
     
    <cfset var returnValue = "" />
     <cfif StructKeyExists(ARGUMENTS,newValue)> 
         <cfset variables.instance.server=arguments.newValue>
   <cfelse>
        <cfset returnValue = variables.instance.server> 
   </cfif>
    
    <cfreturn returnValue />
 </cffunction>
 
then call it either by not passing an attribute to get the value and passing an attribute to set it.
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

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

Reply via email to