> A lot of people will say "NEVER" use the 'this' scope. But I
> say if one understands the differences between the
> 'variables' scope and the 'this' scope (how the former is
> private and the latter is public) and code accordingly, I say
> it is a development choice on which scope one uses.
There really isn't any good reason to have public member variables. It's not
significantly harder to call a method:
<cfset myobj.setvar("myval")>
than to set a variable:
<cfset myobj.var = "myval">
The former approach has a lot of advantages, including the ability to expose
only the things that need to be exposed, and the ability to embed simple
validation logic within the method call. In CF, you also get the additional
advantage of auto-generated documentation. If you use public member
variables they aren't documented by default; you have to use CFPROPERTY to
generate that documentation.
If you're the only programmer working on a project (and the only one who
will ever work on it), you can certainly use public member variables.
However, that doesn't work well when you have multiple programmers, or want
to distribute components, etc. Most things that are considered "best
practices", are considered that because they work well in larger development
environments as well as smaller ones.
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore and Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:260718
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4