You should not use the "this" scope for variables because it makes
variables public accessible. Rather, use "variables" scope because it
makes the variables private. You will have to use a getter method to
retrieve the private data.
<cfcomponent name="Log">
<cfscript>
variables.DEBUG = 0;
variables.INFO = 10;
// and so on..
</cfscript>
<!--- GETTER METHOD --->
<cffunction name="getInfo" access="public" ...>
<cfreturn variables.getInfo>
</cffunction>
</cfcomponent name="Log">
You should check out www.cfcpowertools.com. It's a web based GUI for
generating CFCs. It will generate getter/setter methods for your
properties.
Tom
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Haikal Saadh
Sent: Wednesday, July 06, 2005 6:10 PM
To: [email protected]
Subject: [CFCDev] "public static final" in CFCs?
Hello all.
What's the closest thing CF has to "public static final" in java?
For example, I am writing a logging compoent, and I want to declare some
constants:
<cfcomponent name="Log">
<cfscript>
this.DEBUG = 0;
this.INFO = 10;
// and so on..
</cfscript>
</cfcomponent name="Log">
The idea being that in the client code, I can do something like:
myLogInstance.setLogLevel(Log.DEBUG); // I'm aware that Log.DEBUG
will
// fail, as CF doesn't have
static
// vars either
Now, the trouble with using /this/ is that someone can come along and
reassign the values and it will all end in tears.
What practice does the Rest Of The World use for similar situations?
--
Haikal Saadh, Applications Programmer
Teaching and Learning Support Services
K405, Queensland University of Technology, Kelvin Grove Campus
[EMAIL PROTECTED], 3864 8633
CRICOS No. 00213J
----------------------------------------------------------
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]
----------------------------------------------------------
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]