On Wednesday, Mar 26, 2003, at 22:38 US/Pacific, Nathan Dintenfass wrote:
Sorry for bringing up an old topic, but I could not help notice that Sean's code snippet of the "new
way" to do things uses the "THIS" scope to store what seem like they would be private instance
variables. Since it was Sean who taught me not to use "this" I figured I would ask: Have you
started using "this" for your instance data? If so, why?

No, I don't use "this" scope. I was trying to create a relatively small example and didn't want to add getUsername() and getAuthLevel().


There's no hard and fast rule here: if you want to protect your instance data from outside interference, use something like this:

        <cfcomponent>
                <cfset instance = structNew()>
                <cffunction...>
                        ...
                        <cfset instance.username = ...>
                        ...
                </cffunction>
                <cffunction name="getUsername"...>
                        <cfreturn instance.username>
                </cffunction>
                ...
        </cfcomponent>

If you don't need that level of protection, feel free to use "this" scope.

Hey, I'm not about to get reamed for being a tyrant about "everyone must use non-public data and provide getter/setter functions!"... :)

Sean A Corfield -- http://www.corfield.org/blog/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

----------------------------------------------------------
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).

Reply via email to