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

> > > http://www.sys-con.com/coldfusion/archives/0208/Forta/
> > >
> > > I think Ben explains this pretty good here.
> unfortunately, his article completely contradicts some of the 
> statements made earlier in this thread. Ben says:
> 
> "...CF developers typically create variables in the 
> APPLICATION scope...and are careful never to overwrite 
> them. If an application contained variables like this, 
> variables that were never updated (after initial 
> creation), you wouldn't really need to lock them at all."
> 
> so according to Ben Forta, the only time you need 
> to lock an application variable is when you are 
> changing the value (i.e. CFSET), *NOT* when you are
> simply reading it (i.e. CFOUTPUT). 

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.  If you ARE going to write to it more than that first time,
then you MUST lock the variable every time your write OR read it.  If
you don't lock the reads as well, then the lock on the write will
have no way of knowing if the variable is being read.  In otherwords,
not locking the reads completely defeats the purpose of locking as
other threads would be allowed to read from the variable as it is
being written to EVEN IF THE WRITE WAS IN A LOCK.

> But Zack said in a previous reply:
> 
> "IT IS AN ABSOLUTE NECESITY THAT YOU LOCK ALL SESSION, 
> APPLICATION, AND
> SERVER VARIABLES WHEN YOU WRITE OR READ THEM."

Okay..  I may have overstated that.  Let's say that, "Good CFML
programming practice dictates that IT IS AN ABSOLUTE NECESITY THAT
YOU ......"

Like any good rule, if you really know what you're doing, you can
afford to bend it from time to time.  If you are absolutely certain
that an application/session/server variable will NOT be written to
ever after the initial assignment in the Application.cfm, then you
can afford to not lock it for reads.  If there's any code elsewhere
in the CF application that assigns a value to and ap/ses/serv
variable, then you must lock ALL reads and writes, otherwise it's
possible to cause multiple access problems, and down comes your
server.
 
> i will say that this is one thing that our 
> organization is struggling with... in almost 
> every question, someone says one thing and 
> someone else says another. there doesn't seem 
> to be much agreement anymore in the community. 
> perhaps this is because allaire has changed CF 
> so much with 4 and 4.5, but it certainly doesn't 
> look good when i research something like CFLOCK 
> and create a standard to use it only to find out 
> that someone else is saying otherwise.

There's disagreement for this reason:  

Many CF programmers do not have good training in a "classical"
programming language (C++), and have dealt with little other than
scripting languanges (like CF, ASP, Perl, Python, PHP, etc.) for most
of their programming days.  Scripting languages teach you to think in
a specific way (very task oriented), while allowing you to ignore the
underlying memory, disk, processor, and other archetechural details
to a large degree.  

Unfortunately CFML fails as a true scripting language in that it does
not ALLOW you to ignore many of those details, at least not all of
the time.  The worst part is that most of CFML's weaknesses (like
locking, or non-threadsafe CFX tags, or baddly written TCP/IP tags
(CFHTTP), etc.) do not manifest themselves until you apply lots of
traffic to the application.  And as you all know, by the time you've
applied traffic, it's too late...

Locking especially is an issue that is only a problem at moderate to
high traffic levels.  If you only have 10 visitors a day, OR if
you're developing an application and there's only YOU hitting it with
no other visitors, it's very possible to ignore locking and never see
any problems.  As your traffic grows, however, the excrement will hit
the rotating cooling appliance very quickly....

When you add to that the fact that Allaire seems to change the rules
with every new release.  AND that they never bother to tell you
exactly what the rules are in the first place....  Things aren't
fun...

My experiences have been gathered more or less from scratch.  I used
to shun CF (prefering ASP), but with some very bad ASP experiences
(can you say, "Blue Screen of Death?") and with a HUGE volume site on
the horizon, I switched to CF.  I had to learn all of the do's and
don't's from scratch.  At this point, I'm fairly confident that I've
got it right (a million hits a month & I haven't rebooted the NT
server for over two months!).  I'm always willing to listen to
others' experiences, tho -- I've certainly been dead wrong more than
once in the past...

> anyone else feel like this?

Absolutely.  The developers of CF (not the flunkies who write the
docs for the developers) need to take a hard look at their code &
dictate to us (the users of CF) exactly what you SHOULD, SHOULD NOT,
MUST, and MUST NOT do.  A CFML style guide of sorts, handed down from
on high would be a very GoodThing(tm)....


To summarize this thread, tho...  When in doubt, LOCK IT...

Best regards,
Zac Bedell

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

iQA/AwUBOYLdlAraVoMWBwRBEQJPTACfdABwq8niDGK3MfIqv8onhmikJTMAn1ti
xRp9xGL0k6r98eS0cLA4YqK+
=2Kge
-----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