Very good explanation Jason! I knew that but would not have been able to explain it that good...ha ha !!

On 10/12/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Yes when you're inside you don't need to use getter and setter methods.

<cfset name = "Jason">
<cfset variables.instance.name ="Gerry">

<cfreturn this.name>  <!--- would return Jason --->
<cfreturn variables.instance.name>  <!--- would return Gerry --->

The second is preferable because it encapsulates the data.  The first one
would be accessible outside the object as object.name = "Jason", whereas
the second one would have to be called by object.getName()

Hope this helps.

Jason Cronk





                      "Gurevich, Gerry
                      (NIH/NIEHS)"             To:       [email protected]
                      <[EMAIL PROTECTED]        cc:
                      nih.gov>                 Subject:  RE: [CFCDev] Inside the CFC: use Getter/Setter or Instance Scope
                      Sent by:
                      [EMAIL PROTECTED]
                      one.org


                      10/12/2005 02:29
                      PM
                      Please respond to
                      CFCDev






I have getters and setters.

My question is specifically targeted for when you are inside the CFC.
Shouldn't the methods inside an object have direct access to that object's
properties?

-----------------------------------
Gerry Gurevich
Application Development
NIEHS ITSS Contractor
Lockheed Martin Information Technology
919-361-5444 ext 311

From: Cody Caughlan [mailto: [EMAIL PROTECTED]]
Sent: Wednesday, October 12, 2005 2:10 PM
To: [email protected]
Subject: RE: [CFCDev] Inside the CFC: use Getter/Setter or Instance Scope

Always use getters/setters. This allows for encapsulation.

I use "variables.instance.propertyA", "variables.instance.propertyB", etc.
and then getters/setters for each, e.g.

<cffunction name"getPropertyA" access="public" returntype="WHATEVER">
    <cfreturn variables.instance.propertyA />
</cffunction>

And then you write a function similarly for the setter...

BTW, "Rooibos Generator" by Peter Farrell, accessible at:





From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf
Of Gurevich, Gerry (NIH/NIEHS)
Sent: Wednesday, October 12, 2005 11:01 AM
To: [email protected]
Subject: [CFCDev] Inside the CFC: use Getter/Setter or Instance Scope
If I'm inside a CFC and I've created an instance scope, how should I access
the properties of the object.

this.getBlah  or instance.Blah

Any thoughts?

-----------------------------------
Gerry Gurevich
Application Development
NIEHS ITSS Contractor
Lockheed Martin Information Technology
919-361-5444 ext 311



----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of
the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
( www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]







--
Dan Vega
[EMAIL PROTECTED] ----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at www.mail-archive.com/[email protected]

Reply via email to