Aaron,

I too am on the Safari... I recently was blogging about thinking about
the two different ways. You might want to check it out as far as the
user comments (http://www.bennadel.com/index.cfm?dax=blog:364.view). 

You have to think about what the two scope need to accomplish. Do you
need to "hide" the data? Does data need to be accessible. Many classes
have constants (ex. Paper.A4_LAYOUT). These are clearly not private and
would be stored in the THIS scope. However, if you want to encapsulate
the variables so that people cannot mess with them directly, you might
want to put them in VARIABLES and have getters/setters.

Of course, take that with 2 grains of salt as I am in a similar boat...
Still making my way there.


......................
Ben Nadel
Certified Advanced ColdFusion MX7 Developer
www.bennadel.com
 
Need ColdFusion Help?
www.bennadel.com/ask-ben/

-----Original Message-----
From: Aaron Roberson [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 16, 2006 12:05 PM
To: CF-Talk
Subject: VARIABLES v. THIS in Bean Object

Along with many others, I am finally making my journey through the
"Object Safari" and after much too long I am finally beginning to get
it. The proverbial light is blinking and I am starting to see the
forest. For a while I was trying to look at the forest from the trees,
but I didn't know that I was in the trees.

Now that I am a little more ready to start looking at the trees, two
sets of code examples I am looking at are causing me to wonder if I
should use the VARIABLES scope or the THIS scope in my bean objects.

Here are two different methods which illustrate it:

        <cffunction name="setId" access="public" output="false"
returntype="void"
                        hint="Sets this person's ID">
                <cfargument name="id" type="string" required="true" />
                <cfset variables.id = arguments.id />
        </cffunction>

        <cffunction name="setid" access="public" output="false">
                <cfargument name="id" required="yes">
                <cfset this.id= arguments.id/>
        </cffunction>

Just a quick note: The accessor method using the VARIABLES scope is an
actual bean object while the accessor method using the THIS scope is an
uber-object that also contains CRUD and other Gateway methods. I'm not
sure if that is influenced the choice to use THIS over VARIABLES or
not...

Thanks for all of the help,
Aaron



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:260717
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to