I would use "get" methods to retrieve the values of CFC instance variables instead of copying them to a public scope.


At 11:19 AM 11/15/2004, you wrote:
I do something with "this" scope still. I create a variables.attributes
scope and a private function to set this = duplicate(variables.attributes)
function. Then I use the variables as read only... even if a user messes
with them, they will return the wrong values, but they won't keep the CFC
from having correct internals. If I change anything, I call the set function
again. Let me repeat... they are used as read only... your internal code in
the CFC should never address them, instead I use the variables.attributes
and update the exposed values as read only CFC attributes. Works great for
me, makes the object simpler to acquire attributes.

Just my personal style.

John Farrar

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Patrick McElhaney
Sent: Monday, November 15, 2004 7:50 AM
To: [EMAIL PROTECTED]
Subject: Re: [CFCDev] concerning this / variables scope in cfc

On Sun, 14 Nov 2004 17:28:07 +0100, Magnus Wege <[EMAIL PROTECTED]> wrote:
> So can anybody point me to a link or give examples how and when to use the
> different scopes this/variables?
>
Once I figured it out I created myself a little cheat sheet.

<cfcomponent>
  <cfset variables.private = "A private instance variable">
  <cfset this.public = "A public instance variable">
  <cffunction name="foo">
    <cfargument name="anArgument">
    <cfset var localFooVar = "">
    <cfset localFooVar = "Available within the scope of this function">
    <cfoutput>
      You passed me: #arguments.anArgument#
      I have a local var, whose value is:#localFooVar#.
      I have an private instance variable, whose value is
#variables.private#.
      I have an public instance variable, whose value is #this.public#.
    </cfoutput>
  </cffunction>
</cfcomponent>

Patrick

--
Patrick McElhaney
704.560.9117
http://pmcelhaney.blogspot.com
I still have 5 gmail invites.
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words '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
[EMAIL PROTECTED]

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words '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 [EMAIL PROTECTED]

--
Jeffry Houser, Web Developer, Writer, Songwriter, Recording Engineer
AIM: Reboog711 | Phone: 1-203-379-0773
--
My Books: <http://www.instantcoldfusion.com>
My Recording Studio: <http://www.fcfstudios.com>
My Energetic Acoustic Rock Band: <http://www.farcryfly.com>
--
When did Reality Become TV



----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words '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 [EMAIL PROTECTED]

Reply via email to