Uh... that is a good point. I try to default on the side of "if it doesn't need to be public, don't make it public" - loose variables sink classes.
And while the value would (I believe) switch back on the next request, could you not use the cfc later on in the same request after the change? I am going to shut up now 'cause we are getting beyond stuff I have played with. Rob -----Original Message----- From: Adrocknaphobia Jones [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 2:06 PM To: CF-Talk Subject: RE: CFC - Var vs. This Interesting, as Hal Helm's Discovering CFCs recommends using 'this' to make sure internal CFC variables do not overwrite existing variables. However, var makes much more sense. Kinda. I mean I totally understand its use in object oriented programming, but I even if I was able to change the variable set by 'this' from outside the method; would the variable not be reset to it's hardcoded value when the method is executed (due to the fact we're still procedural)? Or am I wrong in my assumption? Adam Wayne Lehman Web Systems Developer Johns Hopkins Bloomberg School of Public Health Distance Education Division -----Original Message----- From: Matt Liotta [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 4:49 PM To: CF-Talk Subject: RE: CFC - Var vs. This It is a matter of access. Anything existing in the this scope can be accessed from anywhere whether inside the CFC or not. Anything declared with the var keyword is only accessible to the function that declared it and nothing else. It is considered a good programming practice to limit access to variables as much as possible. Thus, if you have no need to access a variable outside of the function to which it is declared then you should use the var keyword. Further, if you have no need to access a variable outside of a CFC then it should not be placed in the this scope. Matt Liotta President & CEO Montara Software, Inc. http://www.montarasoftware.com/ 888-408-0900 x901 > -----Original Message----- > From: Adrocknaphobia Jones [mailto:[EMAIL PROTECTED]] > Sent: Monday, January 06, 2003 4:41 PM > To: CF-Talk > Subject: RE: CFC - Var vs. This > > Right. But what's the difference outside of syntax. Would I want to use > one over the other? Why would I want to use var over this inside a CF is > this is much more flexible? > > Adam Wayne Lehman > Web Systems Developer > Johns Hopkins Bloomberg School of Public Health > Distance Education Division > > > -----Original Message----- > From: Matt Liotta [mailto:[EMAIL PROTECTED]] > Sent: Monday, January 06, 2003 4:14 PM > To: CF-Talk > Subject: RE: CFC - Var vs. This > > The two are very different. "this" is the public variable scope for a > CFC instance. "var" is a keyword used to declare local function > variables. "this" can be used anywhere inside a CFC. "var" can only be > used immediately proceeding a function declaration or argument > specification of a function declaration. > > Matt Liotta > President & CEO > Montara Software, Inc. > http://www.montarasoftware.com/ > 888-408-0900 x901 > > > -----Original Message----- > > From: Adrocknaphobia Jones [mailto:[EMAIL PROTECTED]] > > Sent: Monday, January 06, 2003 4:07 PM > > To: CF-Talk > > Subject: CFC - Var vs. This > > > > Alright, > > > > So Christian says to declare all of your private CFC variables at the > > top of the function like so <cfset var value = 1>. > > Hal Helms recommends using <cfset this.value = 1>. Both obviously > work, > > but I'm wondering what the pros and cons are if any. > > > > Off the top of my head, it would seem that 'this' is more functional, > as > > it acts like any other scope and can be dumped. > > > > Adam Wayne Lehman > > Web Systems Developer > > Johns Hopkins Bloomberg School of Public Health > > Distance Education Division > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

