DevNewz News Archives About Us Feedback
Low Rate eCommerce & Retail Plans

Recent Articles

Dynamic Blogroll For ASP.NET
The blogroll has become a standard element on most blogs today. If it is an ASP.NET blog, the blogroll probably contains links to other ASP.NET blogs...

Programmer Or Coder?
Are programmers and Coders the most neglected link in the Software Development Chain? Coders are like smart assembly line workers as opposed to programmers...

Would Everyone Even WANT To Write Software?
Like many of you, I suspect, I found Awaiting the Day When Everyone Writes Software (you may need to register) in the New York Times interesting. While I...

Implementing PICS And P3P In ASP.NET Headers
PICS (Platform for Internet Content Selection) and P3P (Platform for Privacy Preferences) are two really nice things to be aware of when developing web applications. If your website targets children, maybe you sell toys...

Integrating W/ (Future) Competition
Alex Fletcher has a nice list of hypothetical new year's resolutions for the open source community. I started thinking about his first resolution: "Enable ease...

Software Test Automation And Strategy
Companies are turning to automated testing tools more often than ever before to ensure that their applications are working properly prior to deployment.


03.21.07


Quick Application.cfc Review

By Raymond Camden

A user sent in a request for me to look over some code he would like to use for his Application.cfc file.

(As an aside, don't forget my online Application.cfc template you can use.)

The template looked nice but had one main issue that I noticed. Since the user got the template from someone else, I won't post the whole thing as it isn't my code, but I will demonstrate the problem I saw.

First is the onSessionStart:



Notice that he is keeping count of the sessions, a topic I covered last week. Most importantly though - notice his lock. He is using a scope based lock to ensure his update of the application variable is single threaded. Now lets move on to the onSessionEnd method:



Low Rate eCommerce & Retail Plans



(Forgive the bad formatting - this came in via email.) Notice the problem? Try to figure it out before reading on.

He correctly uses a lock again to update the session count. But he can't use a named lock since the application scope isn't available directly in onSessionEnd. That's why he has to use the application scope passed in via arguments.

So the problem then is that in one case he has a scope based lock and in another case he has a named based lock. He needs to use one or the other. Since he can't use a scope lock in onSessionEnd he should use the named based lock only.

p.s. A few other small things that I'll point out that are minor but bug me: I don't like using cfscript as he did here, just for one line of code. He also forgot the arguments prefix for sessionScope in onSessionEnd. I tend to be anal about using the arguments prefix in my methods.

Comments


About the Author:
Raymond Camden, ray@camdenfamily.com
http://ray.camdenfamily.com

Raymond Camden is Vice President of Technology for roundpeg, Inc. A long time ColdFusion user, Raymond has worked on numerous ColdFusion books and is the creator of many of the most popular ColdFusion community web sites. He is an Adobe Community Expert, user group manager, and the proud father of three little bundles of joy.

About DevNewz
DevNewz has assembled experts around the world to deliver helpful advice to application developers. Our in-house news staff focuses on keeping you updated with the latest new software and trends in application development. DevNewz provides Knowlege For Application Developers.

DevNewz is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
DatabaseProNews.com SQLProNews.com
ITcertificationNews.com SysAdminNews.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com ITmanagementNews.com


-- DevNewz is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
2007 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal

archives | advertising info | news headlines | free newsletters | comments/feedback | submit article


Knowlege For Application Developers DevNewz Home Page About Article Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact