Hi Ryan,
I use request variables for simple values like you have stated. For complex variables
(structures, arrays, queries, objects etc), I use application/session variables
(depending on the needs of the application).
Request vars require no overhead in locking and are easy to change if required without
worrying about resetting application variables. However, they are needed to be set
every request.
Cheers,
Steve
> -----Original Message-----
> From: Ryan Sabir [SMTP:[EMAIL PROTECTED]
> Sent: Friday, 18 June 2004 10:08
> To: CFAussie Mailing List
> Subject: [cfaussie] Setting application constants
>
> Hi all,
>
> I'm just having a think about the best way to set global constants for
> my applications, these are things like datasource names and passwords,
> upload directories etc... as far as I know there are a few ways to set
> these up, these being:
>
> * Setting variables in the Application.cfm file
> e.g. in the Application.cfm file I have a bunch of lines like
> <CFSET dsName = "mydsn">
> <CFSET dsUser = "theuser">
> <CFSET dsPass = "thepass">
>
> then throughout my app, I have lines like:
> <cfquery username="#dsUser#" password="#dsPass#" name="qName"
> datasource="#dsName#">
>
> * Setting session variables
> e.g. in the Application.cfm file I have a bunch of lines like
> <CFLOCK blah>
> <CFIF not isDefined("session.dsName")>
> <CFSET session.dsName = "mydsn">
> <CFSET session.dsUser = "theuser">
> <CFSET session.dsPass = "thepass">
> </cfif>
> <CFSET session_dsName = "mydsn">
> <CFSET session_dsUser = "theuser">
> <CFSET session_dsPass = "thepass">
> </CFLOCK>
>
> then throughout my app, I have lines like:
> <cfquery username="#session_dsUser#" password="#session_dsPass#"
> name="qName" datasource="#session_dsName#">
>
> * Setting application variables
> Same as session variables, but using the application scope with the
> required locks around it.
>
> Now of all the methods above, which is the most efficient and fastest?
> The dumbest way looks like the first method where you are setting
> request scope variables every time any page is called... but the other
> methods involve overhead with locking variables whenever they are
> read.
>
> Is there a best practice for this type of this?
>
> bye!
>
> -----------------------
> Ryan Sabir
> Newgency Pty Ltd
> 2a Broughton St
> Paddington 2021
> Sydney, Australia
> Ph (02) 9331 2133
> Fax (02) 9331 5199
> Mobile: 0411 512 454
> http://www.newgency.com/index.cfm?referer=rysig
>
>
> ---
> You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to
> [EMAIL PROTECTED]
> Aussie Macromedia Developers: http://lists.daemon.com.au/
-----------------------------------------------------------------------------------
This e-mail is sent by Suncorp-Metway Limited ABN 66 010 831 722 or one of its related
entities ("Suncorp").
Suncorp may be contacted at Level 18, 36 Wickham Terrace, Brisbane or on 1800 689 762
or at suncorp.com.au.
The content of this e-mail is the view of the sender or stated author and does not
necessarily reflect the view of Suncorp. The content, including attachments, is a
confidential communication between Suncorp and the intended recipient. If you are not
the intended recipient, any use, interference with, disclosure or copying of this
e-mail, including attachments, is unauthorised and expressly prohibited. If you have
received this e-mail in error please contact the sender immediately and delete the
e-mail and any attachments from your system.
If this e-mail constitutes a commercial message of a type that you no longer wish to
receive please reply to this e-mail by typing Unsubscribe in the subject line.
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Stephen Bosworth
Application Development and Integration
Communication and Information Services
The University of Newcastle, Australia
Phone: 02 4921 6574
Fax: 02 4921 7087
Mobile: 0438 492518
Email: [EMAIL PROTECTED]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/