[thelist] CF: Request for Opinion

Morgan Kelsey morgan at morgankelsey.com
Fri Sep 6 09:48:01 CDT 2002


frank,


>
> I write my apps to be very modular and portable. Frequently,
> there are bits of common information to be shared among the
> apps, such as company info, addresses, contact information,
> etc., or perhaps some small bits of configuration
> information.
>
> Which in your opinion is the better choice:
>
> 1) A cached query
>
> 2) Setting the query to a struct in the application scope
>
> 3) Neither one has a significant overall advantage
> (performance/memory/elegance) over the other
>
> 4) An alternate choice
>

well, in 1 vs. 2 i'd lean toward #1, simnply because i hate cflocking all
the time, which is still recommended for application scope variables....
i think performance differences would be miniscule.

but for static data like company info that's not likely to change -- a
certain, notorious, cf-evolter has gotten me into putting these sorts of
things into local structures, in the Application.cfm template.
something like:

<cfscript>
app = StructNew();

app.rootpath = 'c:\foo\bar\';
app.imgfolder = '/img/';

app.contact =StructNew();
app.contact.address1 = 'street address';
app.contact.city = 'yourtown';
app.contact.state = 'yourstate';
app.contact.email = 'email at comapny.com';
app.contact.phone = '(212)-555-1212';

// etc etc etc
</cfscript>

you may be surprised how fast a *huge* statically declared structure will
execute. i have some real whoppers of application.cfm templates, that
execute in 10-15ms, even though they're declared on every page request.

and now, you dont have to lock, or hit the db, or any of that yucky stuff.


my 2 cents,

nagrom




More information about the thelist mailing list