-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> > That's not strictly true.  If you're never EVER going to 
> > write to the variable (CFSET) beyond the first write, 
> > then you can afford to not lock it.
> 
> True, but since READONLY locks impose just about no 
> performance degredation (unless an exclusive lock is 
> in effect), why not just lock all reads AND writes, 
> no matter how static the variable?  If it truly is a 
> write once, read forever type of value then a bunch 
> of concurrent readonly locks aren't going to do much 
> damage.

Establishing & releasing a lock *does* take some processor time even
if it's a readonly lock w/ no exclusive locks in place.  It's not a
lot, but locks aren't free either.  If you're locking in a case where
you, the programmer, know it isn't nessary, all those locks & unlocks
can add up to some extra processor available.

It's also a matter of convenience.  With something like
Application.DSN that's used on every single page request, it gets
obnoxious to have to lock it every single time.  It's certainly NOT a
bad idea to do it, and if CFStudio added some facility to handle
locking automatically, that'd be nice.  The reason I don't lock every
single read, tho, is mostly because I'm too darn lazy to go in & fix
20,000 lines of code... (I know, I know... Poor me, right? ;-)

 
> On the other hand, if a situation ever WERE to arise where 
> the value was being written do, the readonly locks would 
> kick in.  Better to have the app take a performance hit 
> (even a small one) than risk memory corruption and
> its group of buddies (pCode errors anyone?)

Very true.  Better safe than sorry is certainly the best approach.
 
> Finally, locking ALL access to the shared scopes helps 
> prevent problems in the future. For example, if your 
> application were ever to change in such a way that those 
> once "constant" values become more variable in nature, if
> you've made a habit of locking your reads as well as writes 
> then you won't have to worry.  On the other hand, if you 
> design an app with the assumption that a given variable will 
> never be written more than once, and then that changes, you 
> will have to go back through your code and add a bunch of locks.

That's a matter of good programming practice.  If you define
something as constant, you'd better make sure that it is indeed
constant.  When there's any doubt, I lock it, but for things like
DSNs, ApplicationName, HomePage, AdminEmail, etc., those aren't ever
going to change during code execution.  They MAY change in the
application.cfm if one of those bits of information is renamed, but
in that case, I'd likely restart CFAS to make the changes kick in as
everything is included in if IsDefined("") blocks anyways.

> 
> > Okay..  I may have overstated that.  Let's say that, "Good CFML
> > programming practice dictates that IT IS AN ABSOLUTE NECESITY
> > THAT YOU ......"
> 
> Very well put.
> 
> > Like any good rule, if you really know what you're doing, you can
> > afford to bend it from time to time.
> 
> That's true, but I still don't see how doing so has any 
> benefits, given that readonly locks by themselves don't 
> really harm an application.

Chalk it up to LPD (Lazy Programmer's Disease) -- A truely horrible
malady for certain...

What I'd *like* to see is either a feature added to Studio (That's
right, Allaire.  EARN your $500!), or an add on code sanitizer of
some sort that would act like Java's compiler does.  Some of the
things it should do include:

* Check for locking, and REARRANGE your code if it needs to add
locking (apon your approval, of course).
* Ensure that ALL variables MUST have some value before it allows you
to access them.  For anything that's coming in from a Form, etc., it
should FORCE a CFPARAM tag for that variable.
* Check for syntax errors BEFORE the code is sent to the server.  By
most reports, parsing bad CFML takes its tole on the server over
time, so it'd be nice if something could attempt to PCode a template
before you throw it at the server.
* Check SQL Syntax
* Lots of other good stuff that I can't think of off the top of my
head....

(Hey, I can dream, can't I?...)

Best regards,
Zac Bedell

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.3 for non-commercial use <http://www.pgp.com>
Comment: Please use PGP!!!

iQA/AwUBOYL4FQraVoMWBwRBEQLQ9gCePKTjXlyqIhb9RNwFKiRvSN35oM4An0U6
VYGRXwhHqoRC4MyY2FMJsM0L
=tp8L
-----END PGP SIGNATURE-----
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to