> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of wolf2k5
> Sent: Monday, August 29, 2005 12:29 PM
> To: [email protected]; [email protected]
> Subject: [CFCDev] When to use the THIS scope for a ColdFusion Component?
> 
> Hi all,
> 
> I am new to OOP, but I know CFML pretty well.
> 
> I started playing with ColdFusion Components a couple of years ago and
> I never found a good reason to use the "This" scope.

Although there are good arguments both for and against "this" for data
access (use "this" or use private variables and getter/setter methods) there
is one area in which it's essential: passing back a reference to the
component instance.

In most cases it's good practice to return "this" from your component's
init() method - you can then use the init() method in function calls
requiring an instance of that component.  If you return "this" from your
setters you can chain method calls and the like (a practice which some love
and some hate).

Regardless - to return a reference to the current instance you need "this".

Jim Davis





----------------------------------------------------------
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