I don’t know about best practices or how you can convince someone that it is worth the time.  But I am making a transition from the request scope to a separate datasource.cfc.  I’ve decided not to touch any of my old apps, but I am making the transition for new apps.

 

In my experience, following “best practices” just for the sake of it, even when you don’t see the benefit, often yields unexpected (happy) results later on when your code becomes more  complex and you suddenly realized why all those other people are doing it a certain way.

 

-----------------------------------

Gerry Gurevich

Application Development

NIEHS ITSS Contractor
Lockheed Martin Information Technology
919-361-5444 ext 311


From: Ryan Everhart [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 22, 2006 1:27 PM
To: [email protected]
Subject: Re: [CFCDev] Storing DSN parameters in a "global" variable

 

Cody,
I'm interested in this question as well.  We use the put our DSN in the request scope just as you mentioned.

Ryan

On 3/22/06, Cody Caughlan <[EMAIL PROTECTED]> wrote:

Is there anything inherently wrong with storing your DSN parameters in a
Request-scoped structure and referring to these in your cfquerys, e.g.:

<!--- pseudo-code --->
App.cfc::onRequestStart() {
         Request.DSU = "myDBUser";
        Request.DSP = "myDBPassword";
        Request.DSN = "myDSN";
        Request.DST = "ODBC";
}

.... later, in some code deep in your app...

<cfquery name="foobar" datasource="#Request.DSN#" username="#Request.DSU#"
password="#Request.DSP" type="#Request.DST#">
        ....
</cfquery>


Apart from the encapsulation this *does not* give you, is there anything
wrong with this? That is, your code is now tied to the Request scope. I
*know* it would be much better to pass every DSN struct into your CFC that
needs it (possibly using some kind of a centralized object factory like
ColdSpring). I have a fellow developer who prefers this "global" approach. I
say its bad, he says its OK, because Macromedia (now Adobe) will never take
away the the REQUEST structure, so its not like the code will ever break. My
argument is that its not "proper coding", his argument is the magnitude of
convenience this affords.

Whats the right answer?

Thanks
/Cody




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

An archive of the CFCDev list is available at www.mail-archive.com/[email protected]




--
Ryan Everhart
[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).

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

An archive of the CFCDev list is available at www.mail-archive.com/[email protected]

Reply via email to