All right. I can see the difference from your example. Now, just to be like the proverbial toddler that doesn't know when to stop asking "why"...
Now explain <cfproperty>. In the example below, for example, what would be different if you made ID a property of the human object rather than a non-var local variable? In that case would ID be something that *is* viewable/changeable by the user (which would be a bad idea for an ID, of course). If I wanted info that the user could see or change, why would I decide to do this.name rather than <cfproperty name="name">? I'd love to promise that I'll stop after this one. -Patti On 7/17/02 4:49 PM, "Raymond Camden" <[EMAIL PROTECTED]> wrote: >> Wait... I just got confused. Why is it more private if you >> don't var the variable? I get the "This" aspect just fine. >> But if by not var-ing, you run the risk of variable >> overwriting when calling cfcs from other cfcs, then why is it >> "more local" or "private" not to var? >> > > > Sorry, let me back up a bit. > > Imagine a CFC that looks like so: > > <cfcomponent displayName="human"> > > <cfset this.name = "Nameless"> > <cfset this.age = 0> > > <!--- various methods ---> > > </cfcomponent> > > What I have here is the bare skeleton of a "human" CFC. I also define to > variables, name and age, in the this scope. These values are public. If > I make an instance of "human" called Ray, I can output ray.name. > > So - it's not that much of a stretch to imagine needing data that is NOT > public. For example, maybe ID: > > <cfset this.name = "Nameless"> > <cfset this.age = 0> > <cfset ID = createUUID()> > > The ID value will persist along with name and age, but will not be > viewable/changeble by the user. > > So - how would you use this data in methods? You would treat it as any > other global variable. That means if you have methods that also use the > variable ID, but you mean it to be a temp var, you would need to var > scope them. > > The basic idea is - if you use data that is NOT "This" scoped or "var" > scoped, you can consider it as a private variable. As long as you are > anal about var scoping everything else, these values will be safe. > > Make sense? > > Before certain people jump on me - I am NOT saying this is 100% like the > private scope in Java. I'm just saying it acts like a set of data that > is private to the CFC. Enjoy. Use it or not - it's up to you. > > ======================================================================= > Raymond Camden, ColdFusion Jedi Master for Macromedia > > Email : [EMAIL PROTECTED] > Yahoo IM : morpheus > > "My ally is the Force, and a powerful ally it is." - Yoda > > ______________________________________________________________________ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists