Your "CFGURU dude" is correct.  Publicly exposing data allows direct access
to that data rather than forcing developers to access the data via get/set
methods.  This is dangerous because often times, you need to run enumeration
and/or other methods in addition to changing a property value.  Consider
this simple example - suppose you have a shopping cart, and every time an
item is added or it's quantity changed, the cart component runs a method to
calculate shipping, tax, subtotals, and cart total so far.  Allowing direct
access to the quantities of items in the cart would allow for quantity
values to change without the tax, shipping, subtotals, and cart total values
being updated to reflect the new contents of the cart.  Making all of this
data private, and creating a setQuantity() method that allows the quantity
of any item in the cart to be changed, prevents the earlier scenario by
maintaining control over the cde that is executed whenever a cart item
quantity changes.

~Simon

Simon Horwith 
Macromedia Certified Instructor 
Certified Advanced ColdFusion MX Developer 
Certified Flash MX Developer 
CFDJList - List Administrator 
Fig Leaf Software 
1400 16th St NW, # 220 
Washington DC 20036 
202.797.6570 (direct line) 
www.figleaf.com 



-----Original Message-----
From: Scott Barnes [mailto:[EMAIL PROTECTED] 
Sent: Sunday, March 30, 2003 2:42
To: [EMAIL PROTECTED]
Subject: [CFCDev] this.scope vs private.scope 


I have been researching the reasons for using private variables within a cfc
vs using the public this.scope concept? I was wondering if anyone has any
thoughts on this thus far?

One thing that a fellow CF`GERU dude mentioned was that people could bypass
the setter/getter methods and go directly to manipulation of the
'object.property = ""' thus at the end of the objects save() to data layer,
could become problematic (ie expecting a boolean value and they mispelled
true with say trrue or something silly like that.

Whats the peers of the community have to say on such a matter?

Scott Barnes 
Snr Developer
eCommerce Department
Tourism Queensland / Sunlover Holidays
[EMAIL PROTECTED]
ph: (07) 3535 5066 

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

Reply via email to