This (or something very similar) has come up before.  I personally
like using the getters and setters everywhere, as they are the 'real'
properties of the CFC, not the instance variables.  At least that's
the theory.  As for overhead, there definitely is some, but it's going
to be quite minimal, and can be safely ignored, IMHO.

cheers,
barneyb

On Mon, 3 Jan 2005 15:17:46 -0600, Dawson, Michael <[EMAIL PROTECTED]> wrote:
> I have a simple CFC that has a few instance variables in it.
> 
> <cfcomponent>
> <cfset variables.instance = structNew()>
> <cfset variables.instance.firstName = "">
> <cfset variables.instance.lastName = "">
> 
> ...
> 
> </cfcomponent>
> 
> In this component, I have the pairs of getters and setters such as:
> 
> <cffunction name="setFirstName">
> ...
> </cffunction>
> 
> <cffunction name="getFirstName">
> ...
> </cffunction>
> 
> I also have a validate method that needs to check the values of the
> instance variables.  Which is the "better form" of accessing the
> instance varibles?
> 
> 1. <cfif not len(variables.instance.firstName)>...</cfif>
> Or
> 2. <cfif not len(getFirstName())>...</cfif>
> 
> At first glance, the second option is shorter and would still
> encapsulate any logic even inside its own CFC.  Would there be any
> substantial overhead with calling a method over an instance variable?
> 
> Thanks
> M!ke
> 

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/

Got Gmail? I have 9 invites.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - New Atlanta
http://www.newatlanta.com

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:189174
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to