> I understand that CF doesn't have the notion of constants, 
> but I thought that by setting <cfset application.constInt = 5> 
> and by never changing it during the execution of the application 
> in fact (for all practical purposes) we declared a constant.
> It seams that the general agreement among people on the list 
> is that even in those cases we should use readonly locks (or 
> set them up with request scope). Which probably is OK but if 
> you have 100 (or more of those) to set them up for each page 
> it looks to me like a waste of time (even if very small, which 
> probably is less than having 50 readonly locks on each page).
> 
> Ben Forta in the August edition of CFDJ said that if you are 
> ABSOLUTELY sure that a variable (application,session or server) 
> doesn't change you can leave out the readonly lock.
> 
> So my question is: should we lock constants or no?

I'd strongly recommend locking all instances of persistent memory variables
(Session, Application, Server), no matter what. Ben Forta won't come out to
fix your application if it crashes.

If you would rather not have CFLOCKs sprinkled throughout your code, you
have a couple of options. You could copy the Application scope to a
structure in local memory at the top of a script which will need it. Or, if
you want to emulate constants, you could simply use the Request scope, which
is my recommendation.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to