variables.instance.varname will create a "protected" variable. That means it can be accessed inside the CFC and by any descendants of the CFC, however it cannot be accessed outside the CFC. ( Sean described the difference between protected and private earlier in this thread). The variable it creates is a structure named instance with a key of "varname". ( I assume most of your CFCs have more than one instance variable of course... )


this.variables.instance.varname will create a public variable. That means it can be accessed from within the CFC, within its descendants, and from outside the CFC. Unless I miss my guess, it will create a structure called variables (probably not a good name for a variable) with a "key" named instance. Instance is actually another structure, which contains a key named varname.


so..

variables.ThisVar   cannot be accessed using componentInstance.ThisVar
this.ThisVar can be accessed using componentInstance.ThisVar

Make sense? I've never "this", but I assume structures inside the 'scope' can be accessed in the same manner ( componentInstance.this.variables.instance.varname )


At 06:44 PM 11/14/2004, you wrote:
I didn't realize that the THIS scope was public, I used the developer study guide as my reference and thought it referred to the private scope of each instance of a CFC...

I took an intro Java class and trying to put things to work in CF.
Previously I had placed all instance variables in the variables scope, so basically at the top of the CFC I would declare variables.instance.varname for each instance variable...and then I decided to change it to this.variables.instance.varname... now I'm confused, whats the difference?


-Steve


--------------------------------------------- Steven Boynes 580 37th Avenue San Francisco, CA 94121 (530)574-2129 (Home/Mobile)



>From: Sean Corfield <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: [EMAIL PROTECTED]
>Subject: Re: [CFCDev] concerning this / variables scope in cfc
>Date: Sun, 14 Nov 2004 09:01:45 -0800
>
>On Sun, 14 Nov 2004 17:28:07 +0100, Magnus Wege
<[EMAIL PROTECTED]> wrote:
> > In the overview it is mentioned that you shouldn't use the
variables scope
> > ("avoid using").
>
>That's very out-of-date as it refers to bugs in CFMX 6.0 that have
>been fixed for two years (with CFMX 6.1).
>
> > Though Nando is right that the "this" scope is available
to
> > the caller which breaks the encapsulation paradigm.
>
>"this" scope is the equivalent to "public" data
members - and all the
>literature out there will tell you not to use public data members.
>
>"variables" scope is the equivalent of "protected"
data members. If
>your object needs state information, it will use "variables"
scope.
>"variables" scope exists for the lifetime of the CFC instance
(which
>depends on the scope in which the CFC instance itself is stored).
>
>"var" - not exactly a scope, but you should use it to declare
any and
>all variables that should be local to a specific function call. Such
>variables are created fresh for each function call and exist only
>inside that function.
>
> > -----Ursprüngliche Nachricht-----
>
>And you really need to trim your posts...
>
>[many hundreds of lines deleted]
>--
>Sean A Corfield -- http://www.corfield.org/
>Team Fusebox -- http://www.fusebox.org/
>Breeze Me! -- http://www.corfield.org/breezeme
>Got Gmail? -- I have 1 invite
>
>"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 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