I won't say this is bettere, this is just an idea I've been using. For every
application, I'll create a CFC with the same name as the app itself, or a
CFC called "settings". This CFC will have a method, getSettings, that
returns a struct. This struct contains all the stuff I used to store in
application vars. DSN names. Mappings. Settings. Etc.

So, in my Application.cfm file, I'll have something like this:

<cfif not isDefined("application.settings") or
isDefined("url.reinitmebaby")>
<cfinvoke component="cfcs.settings" method="getSettings"
returnVariable="settings">
<cfset application.settings = settings>
</cfif>

This then allows me to use these settings in my code. In my CFCs, the
constructor area will have the exact same code, pretty much...

<cfinvoke component="cfcs.settings" method="getSettings"
returnVariable="variables.settings">

Then methods can use #variables.settings.dsn#, or whatever. This means that
all my CFCs and other code use the same API to get settings. It also means
my CFCs aren't required to use Application variables.
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to