<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>Mike Schierberl&apos;s Blog - varScoper</title>
			<link>http://www.schierberl.com/cfblog/index.cfm</link>
			<description>Mike Schierberl&apos;s thoughts on software development and coldfusion</description>
			<language>en-us</language>
			<pubDate>Sun, 05 Sep 2010 12:53:05 -0700</pubDate>
			<lastBuildDate>Mon, 27 Jul 2009 22:29:00 -0700</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>mike@schierberl.com</managingEditor>
			<webMaster>mike@schierberl.com</webMaster>
			
			
			
			
			
			<item>
				<title>varScoper 1.30 release with CF Builder extension</title>
				<link>http://www.schierberl.com/cfblog/index.cfm/2009/7/27/varScoper-130-release-with-CF-Builder-extension</link>
				<description>
				
				varScoper 1.30 is now available to &lt;a href=&quot;http://varscoper.riaforge.org/index.cfm?event=action.download&quot;&gt;download on RIAForge&lt;/a&gt;.  This release fixes over 17 reported issues and also works properly on both Railo and OpenBD.

Additionally, &lt;a href=&quot;http://www.coldfusionjedi.com&quot;&gt;Raymond Camden&apos;s&lt;/a&gt; ColdFusion builder extension code has been integrated.  Hopefully the consolidation will make life easier for everyone. You can either install the zip, or import the extension if it&apos;s already unpacked.  In case you haven&apos;t used it yet, this feature allows you to right click on a file or folder in CF Builder and run varScoper directly from the IDE.

At the moment, this release will not correctly identify variables based on CF9 syntax (LOCAL scope and ability to identify var anywhere in a function).  The test cases are in place and I&apos;ll be working on it soon.  As a result you will notice the unit test will throw an error if you aren&apos;t running cf9.

Thanks again to Ray, Pat Santora, and everyone else who has reported issues.  If you have any problems, please &lt;a href=&quot;http://varscoper.riaforge.org/index.cfm?event=page.issues&quot;&gt;report them at RIAForge&lt;/a&gt; and I will get to them eventually.
				
				</description>
						
				
				<category>varScoper</category>				
				
				<category>coldfusion</category>				
				
				<pubDate>Mon, 27 Jul 2009 22:29:00 -0700</pubDate>
				<guid>http://www.schierberl.com/cfblog/index.cfm/2009/7/27/varScoper-130-release-with-CF-Builder-extension</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Thread safety and the var scope - live example</title>
				<link>http://www.schierberl.com/cfblog/index.cfm/2008/7/21/Thread-safety-and-the-var-scope--live-example</link>
				<description>
				
				Recently, I&apos;ve talked to a few developers who knew about the var scope, but didn&apos;t quite grasp the concept of making a variable local to a function.  Additionally, I&apos;ve come across a few posts that indicated that setting a var statement was strictly to conserve memory (along with other reasons that missed the point). 

To help anyone struggling with understanding the impact of the var scope I&apos;ve put together a quick example to demonstrate what can happen when you improperly scope a variable.

The example here focuses on CFCs that are loaded into a shared scope (session, application, etc), and are accessed simultaneously by multiple users.Running the code will make 2 simultaneous requests to the same function in separate iframes. The example contains a loop that outputs the index of a loop from 1 to 100.  If the loop executes correctly the numbers appear in green, if the numbers are out of sequence, they will be red.  To make the results more dramatic I&apos;ve included a 1-40ms pause in each loop iteration.

&lt;a href=&quot;javascript:goTest(&apos;var&apos;);&quot;&gt;run example with var statement&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;javascript:goTest(&apos;nonVar&apos;);&quot;&gt;run example without var statement&lt;/a&gt;&lt;br&gt;
&lt;table border=&quot;0&quot;&gt;
	&lt;tr&gt;
		&lt;td width=&quot;50%&quot;&gt;&lt;iframe src=&quot;/cfblog/threadExample/blank.html&quot; border=&quot;0&quot; height=&quot;175&quot; width=&quot;100%&quot; name=&quot;leftFrame&quot;&gt;&lt;/iframe&gt;&lt;/td&gt;
		&lt;td width=&quot;50%&quot;&gt;&lt;iframe src=&quot;/cfblog/threadExample/blank.html&quot; border=&quot;0&quot; height=&quot;175&quot; width=&quot;100%&quot; name=&quot;rightFrame&quot;&gt;&lt;/iframe&gt;&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;

Here&apos;s the cfc that is loaded in server scope (simplified for reading).  Note the only difference in the functions is that the &quot;count&quot; variable has a var statement in one function and doesn&apos;t in the other function.

&lt;code&gt;
&lt;cfcomponent name=&quot;thread&quot;&gt;
	
	&lt;cffunction name=&quot;nonVarFunction&quot; &gt;
		&lt;cfset var lastCount = 0&gt;
		&lt;cfset var idx = 0&gt;
		
		&lt;cfset count = 0&gt;
		
		executing &quot;nonVarFunction()&quot;&lt;br/&gt;
		
		&lt;cfloop from=&quot;1&quot; to=&quot;100&quot; index=&quot;idx&quot;&gt;
			&lt;cfset lastCount = count&gt;
			&lt;cfset count = count + 1&gt;
			&lt;cfthread action=&quot;sleep&quot; duration=&quot;#randRange(1,40)#&quot; /&gt;
			&lt;cfoutput&gt;
				&lt;cfif count-1 EQ lastCount&gt;
				   &lt;!--- display green---&gt;
				   #count#
				&lt;cfelse&gt;
				   &lt;!--- display red---&gt;
				   #count#
				&lt;/cfif&gt;
			&lt;/cfoutput&gt;
			&lt;cfflush&gt;
		&lt;/cfloop&gt;
	&lt;/cffunction&gt;
	
	&lt;cffunction name=&quot;VarFunction&quot; &gt;
		&lt;cfset var lastCount = 0&gt;
		&lt;cfset var idx = 0&gt;
		
		&lt;cfset var count = 0&gt;
		
		executing &quot;VarFunction()&quot;&lt;br/&gt;
		
		&lt;cfloop from=&quot;1&quot; to=&quot;100&quot; index=&quot;idx&quot;&gt;
			&lt;cfset lastCount = count&gt;
			&lt;cfset count = count + 1&gt;
			&lt;cfthread action=&quot;sleep&quot; duration=&quot;#randRange(1,40)#&quot; /&gt;
			&lt;cfoutput&gt;
				&lt;cfif count-1 EQ lastCount&gt;
				   &lt;!--- display green---&gt;
				   #count#
				&lt;cfelse&gt;
				   &lt;!--- display red---&gt;
				   #count#
				&lt;/cfif&gt;
			&lt;/cfoutput&gt;
			&lt;cfflush&gt;
		&lt;/cfloop&gt;
	&lt;/cffunction&gt;
&lt;/cfcomponent&gt;
&lt;/code&gt;

What happened?

If the example executed correctly, you should have seen all green numbers in both windows for the var scope example, and a mix of green and red in the example that executed the function without the var statement.  The presence of the &quot;var&quot; statement makes the variable local to the function.  This means that when the function runs, it creates a new instance of the variable that is unique each time the function is executed.  Without the var statement in place, the variable gets &quot;shared&quot; between everyone who is accessing this component.  When a component lives in a shared scope (session, application) the variable will be shared for everyone accessing that scope.  Think of the following scenario.

User 1: set count = 1&lt;br/&gt;
User 2: set count = 1&lt;br/&gt;
User 1: set count = count + 1&lt;br/&gt;
User 2: set count = count + 1&lt;br/&gt;
User 1: count = 2&lt;br/&gt;
User 2: count = 3&lt;br/&gt;

In this case the developer most likely intended to have both users see count = 2, however the variable was shared and as a result a user&apos;s result was impacted by another user&apos;s request.  Note: this may be the intended behavior of the code, and that&apos;s why there is no definite rule on why you should &quot;always&quot; or &quot;never&quot; var scope a variable.

Unfortunately, recognizing issues that appear as a result of improper scope can be difficult.  Many times they result in server errors that are intermittent and only appear under load.  This can sometimes make it practically impossible to reproduce the error in a test environment.  Also, many tags create variables that are easy to miss (cfquery, cfloop, etc).  

Luckily, there&apos;s a tool to help (shameless plug here).  Take a look at &lt;a href=&quot;http://varscoper.riaforge.org/&quot;&gt;varscoper&lt;/a&gt;.  Hopefully this will become an integral tool in your development process.
				
				</description>
						
				
				<category>varScoper</category>				
				
				<category>coldfusion</category>				
				
				<pubDate>Mon, 21 Jul 2008 17:18:00 -0700</pubDate>
				<guid>http://www.schierberl.com/cfblog/index.cfm/2008/7/21/Thread-safety-and-the-var-scope--live-example</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>New varScoper release candidate</title>
				<link>http://www.schierberl.com/cfblog/index.cfm/2008/6/25/new-varscoper-release-candidate</link>
				<description>
				
				A new release candidate is available for my varScoper tool.&lt;br&gt;&lt;br&gt;
&lt;a href=&quot;http://www.schierberl.com/varscoper/download.cfm?rc=true&quot;&gt;varscoper_1_30_RC.zip&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Please download and run against your code.  If you find any issues please report them at &lt;a href=&quot;http://varscoper.riaforge.org/index.cfm?event=page.addissue&quot;&gt;RIAForge&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;
Thank you to everyone who provided feedback on 1.21.  At least 16 bugs were identified and are now fixed in the RC.  All reported issues and corner cases have been added to the unit test to ensure that it won&apos;t break the same way in the future.  Additionally, thank you to &lt;a href=&quot;http://patweb99.avatu.com/&quot;&gt;Pat Santora&lt;/a&gt;, who was responsible for a majority of the fixes.
&lt;br&gt;&lt;br&gt;
Finally, based on feedback, I&apos;ve included a cfset statement generator to generate blocks of cfset var statements.  However, I take no responsibility for the consequences of using this generated code.
				
				</description>
						
				
				<category>varScoper</category>				
				
				<category>coldfusion</category>				
				
				<pubDate>Wed, 25 Jun 2008 18:12:00 -0700</pubDate>
				<guid>http://www.schierberl.com/cfblog/index.cfm/2008/6/25/new-varscoper-release-candidate</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>quick varScoper update</title>
				<link>http://www.schierberl.com/cfblog/index.cfm/2008/5/22/quick-varScoper-update</link>
				<description>
				
				Version 1.21 of varscoper is now available to &lt;a href=&quot;http://www.schierberl.com/varscoper/download.cfm&quot;&gt; download &lt;/a&gt;.  This is a minor update that fixes some of the CF6, CF7, and *nix issues that were reported when I released 1.20.

Additionally, there was a minor fix to cfscript parsing when using a function inside a struct set. Something similar to this...

&lt;code&gt;
mystruct[someFunction()] = &quot;&quot;;
&lt;/code&gt;
				
				</description>
						
				
				<category>varScoper</category>				
				
				<category>coldfusion</category>				
				
				<pubDate>Thu, 22 May 2008 09:37:00 -0700</pubDate>
				<guid>http://www.schierberl.com/cfblog/index.cfm/2008/5/22/quick-varScoper-update</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>varScoper 1.20 - critical update</title>
				<link>http://www.schierberl.com/cfblog/index.cfm/2008/5/20/varScoper-120-released--critical-update</link>
				<description>
				
				Version 1.20 of varscoper is now out on &lt;a href=&quot;http://www.riaforge.com/&quot;&gt;RIAForge&lt;/a&gt;.  It&apos;s also available directly from the &lt;a href=&quot;http://www.schierberl.com/varscoper/download.cfm&quot;&gt;download link&lt;/a&gt;.  
&lt;br&gt;&lt;br&gt;
Many thanks to &lt;a href=&quot;http://patweb99.avatu.com/&quot;&gt;Pat Santora&lt;/a&gt; for this release.  The majority of the content in this release is a direct result of his hard work.

&lt;h3&gt;Updates&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Improvements to cfscript parsing engine&lt;/strong&gt;
&lt;ul&gt;&lt;li&gt;RIAForge issues 6,7,8,9,10,11 are fixed&lt;/li&gt;
&lt;li&gt;Improved handling of script comments&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;strong&gt;Ability to exclude files/folders&lt;/strong&gt;
&lt;ul&gt;&lt;li&gt;configured through properties.xml&lt;li&gt;Ability to exclude individual files or directories from your search&lt;/ul&gt;
&lt;li&gt;&lt;strong&gt;Integrated Unit Testing&lt;/strong&gt;
&lt;ul&gt;&lt;li&gt;testCaseCFC.cfc now includes positive/negative test cases for all reported issues
&lt;li&gt;Currently still reporting 2 known issues that will be addressed in a future release 
&lt;/ul&gt;
&lt;li&gt;&lt;strong&gt;Improvements to parsing engine&lt;/strong&gt;
&lt;ul&gt;&lt;li&gt;Fix for Ray&apos;s cffeed bug (also fixes cfprocparam)
&lt;li&gt;More agressive var scope checking (re-run against all your code, we found 2 new unscoped vars at Planitax)&lt;/ul&gt;

&lt;/ul&gt;
				
				</description>
						
				
				<category>varScoper</category>				
				
				<category>coldfusion</category>				
				
				<pubDate>Tue, 20 May 2008 22:17:00 -0700</pubDate>
				<guid>http://www.schierberl.com/cfblog/index.cfm/2008/5/20/varScoper-120-released--critical-update</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Minor update to varscoper</title>
				<link>http://www.schierberl.com/cfblog/index.cfm/2007/12/6/Minor-update-to-varscoper</link>
				<description>
				
				I just released a 1.12 update to my varscoper tool.&amp;nbsp; I&apos;ve added new tags to the parsing engine, added XML output support, and fixed some bugs related to directory parsing in CF6.&amp;nbsp; Thanks to   Kola Oyedegi for help with XML output and Dmitriy Goltseker for fixing directory processing.&amp;nbsp; Thanks to everyone who helped to refine the list of tags that create variables.&amp;nbsp; The additions are below.&amp;nbsp; You can also &lt;a href=&quot;http://www.schierberl.com/varscoper/download.cfm&quot;&gt;download 1.12 here&lt;/a&gt; , or get it via SVN on riaforge.&lt;br /&gt;
&lt;ul&gt;
    &lt;li&gt;cfhttp:result  &lt;/li&gt;
    &lt;li&gt;cfquery:result&lt;/li&gt;
    &lt;li&gt;  cfimage:name&lt;/li&gt;
    &lt;li&gt;  cfmail:query&lt;/li&gt;
    &lt;li&gt;  cffeed:name&lt;/li&gt;
    &lt;li&gt;  cffeed:query&lt;/li&gt;
    &lt;li&gt;  cfftp:name&lt;/li&gt;
    &lt;li&gt;  cfwddx:output&lt;/li&gt;
    &lt;li&gt;  cfobject:name&lt;/li&gt;
    &lt;li&gt;  cfsearch:name&lt;/li&gt;
    &lt;li&gt;  cfprocresult:name&lt;/li&gt;
    &lt;li&gt;  cfpop:name&lt;/li&gt;
    &lt;li&gt;  cfregistry:name&lt;/li&gt;
    &lt;li&gt;  cfreport:name&lt;/li&gt;
    &lt;li&gt;  cfdbinfo:name&lt;/li&gt;
    &lt;li&gt;  cfdocument:name&lt;/li&gt;
    &lt;li&gt;  cfexecute:variable&lt;/li&gt;
    &lt;li&gt;  cfNtAuthenticate:result&lt;/li&gt;
    &lt;li&gt;  cfcollection:name&lt;/li&gt;
    &lt;li&gt;  cfpdf:name&lt;/li&gt;
    &lt;li&gt;  cfxml:variable&lt;/li&gt;
    &lt;li&gt;  cfzip:name&lt;/li&gt;
    &lt;li&gt;  cfldap:name&lt;/li&gt;
&lt;/ul&gt;
				
				</description>
						
				
				<category>varScoper</category>				
				
				<category>coldfusion</category>				
				
				<pubDate>Thu, 06 Dec 2007 12:44:00 -0700</pubDate>
				<guid>http://www.schierberl.com/cfblog/index.cfm/2007/12/6/Minor-update-to-varscoper</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Can you name all the tags that create variables?</title>
				<link>http://www.schierberl.com/cfblog/index.cfm/2007/10/22/Can-you-name-all-the-tags-that-create-variables</link>
				<description>
				
				As part of the development effort on my &lt;a href=&quot;http://www.schierberl.com/varscoper&quot;&gt;var-scoping tool&lt;/a&gt; I have been trying to identify all of the tags that can create variables.&amp;nbsp;&amp;nbsp; I have yet to find a comprehensive listing of tags, so I&apos;m hoping that people can leave comments here to expand the list.&lt;br /&gt;
&lt;br /&gt;
Here&apos;s my partial list to start with (yes I know it&apos;s small), along with the parameter that specifies the variable name.&amp;nbsp; Please comment on my blog and add on any that I&apos;ve missed.&lt;br /&gt;
&lt;br /&gt;
cfloop:index&lt;br /&gt;
cfloop:item&lt;br /&gt;
cfquery:name&lt;br /&gt;
cfinvoke:returnvariable&lt;br /&gt;
cfdirectory:name&lt;br /&gt;
cffile:variable&lt;br /&gt;
cfparam:name&lt;br /&gt;
cfsavecontent:variable&lt;br /&gt;
cfform:name&lt;br /&gt;
cfstoredproc:name&lt;br /&gt;
cfprocparam:variable&lt;br /&gt;
				
				</description>
						
				
				<category>varScoper</category>				
				
				<category>coldfusion</category>				
				
				<pubDate>Mon, 22 Oct 2007 16:44:00 -0700</pubDate>
				<guid>http://www.schierberl.com/cfblog/index.cfm/2007/10/22/Can-you-name-all-the-tags-that-create-variables</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>varScoper 1.1 - now with cfscript parsing</title>
				<link>http://www.schierberl.com/cfblog/index.cfm/2007/10/7/varScoper-11--now-with-cfscript-parsing</link>
				<description>
				
				That&apos;s right, my varScoper tool now supports cfml written within cfscript blocks.&amp;nbsp; Please note that this is still somewhat experimental, but seems to handle quite a few scenarios.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.schierberl.com/varscoper/download.cfm&quot;&gt;Click here to download the 1.1 code.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.schierberl.com/varscoper&quot;&gt;Here&apos;s a link to the project page.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Many thanks to &lt;a href=&quot;http://zacster.blogspot.com/&quot;&gt;Zac Spitzer&lt;/a&gt; who is responsible for writing the code to identify var statements within cfscript.&amp;nbsp; He completed the cfscript var statement support as a response to &lt;a href=&quot;http://www.nodans.com/index.cfm/2007/9/27/Is-your-code-Thread-Safe-How-do-you-know&quot;&gt;this post&lt;/a&gt;.&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
After looking at Zac&apos;s code, I decided to take it to the next level and complete the code required to identify variables created within cfscript blocks.&lt;br /&gt;
&lt;br /&gt;
The code will even ignore variables created within comments, but unfortunately does not include the ability to identify the line number of the variable (which it does within tags).&amp;nbsp; You can still jump directly to the method, but you&apos;re on your own to find the variable.&lt;br /&gt;
&lt;br /&gt;
You can even identify variables created within for loops and if/else blocks.&amp;nbsp; Here&apos;s an example...  &lt;br /&gt;
&lt;code&gt;
for(correctLoop=1;correctLoop LTE 10; correctLoop=correctLoop+1) correctSimpleVar = correctLoop;&lt;/code&gt;  &lt;br /&gt;
In this example correctLoop, and correctSimpleVar will both be identified with the tool.&lt;br /&gt;
&lt;br /&gt;
For those of you who aren&apos;t aware of varscoper, it is a code analyzer that will look for variables without a var statement that exist within a cffunction.&amp;nbsp; I released the tool last July and cfscript support has been the #1 request.&lt;br /&gt;
&lt;br /&gt;
Additionally, I am now hosting the project at RIAforge at &lt;a href=&quot;http://varscoper.riaforge.org/&quot;&gt;http://varscoper.riaforge.org/&lt;/a&gt;, you can look there for SVN access.&lt;br /&gt;
&lt;br /&gt;
Please take a minute to test out the code and please let me know ASAP if you can find any cases that the cfscript code doesn&apos;t cover.
				
				</description>
						
				
				<category>varScoper</category>				
				
				<category>coldfusion</category>				
				
				<pubDate>Sun, 07 Oct 2007 19:43:00 -0700</pubDate>
				<guid>http://www.schierberl.com/cfblog/index.cfm/2007/10/7/varScoper-11--now-with-cfscript-parsing</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>varScoper 1.0 release</title>
				<link>http://www.schierberl.com/cfblog/index.cfm/2006/7/20/varScoper-10-release</link>
				<description>
				
				Today I am releasing version 1.0 of a project that I&apos;ve been working on for a few weeks.   It&apos;s a cfc that can be used to parse cfm and cfc files and identify variables that haven&apos;t been locally scoped within cffunctions.&lt;br&gt;&lt;br&gt;

varScoper can do the following....&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Find unscoped variables created with a cfset within a cffunction 
&lt;li&gt;Find unscoped variables created with cftags (cfloop, cfquery, etc) 
&lt;li&gt;Report line numbers and link directly to the line in the file
&lt;li&gt;Output to screen or csv
&lt;/ul&gt;



Hopefully everyone else will find this as useful as I do.  There&apos;s a link in my projects section to the project page, or you can follow this link.

&lt;a href=&quot;http://www.schierberl.com/varScoper&quot;&gt;varScoper 1.0&lt;/a&gt;

You might be surprised at the results you find.  I&apos;ve been careful to scope my vars within the last few years, but I found an alarming number of potential problems in some of the code I was writing a few years ago when I first started with CFCs.  In any case, try downloading the sample code, run it against your codebase, and do some housecleaning.  
&lt;br&gt;&lt;br&gt;
Here&apos;s a screenshot&lt;Br&gt;

&lt;a href=&quot;#&quot; onclick=&quot;window.open(&apos;http://www.schierberl.com/cfblog/images/varScoperScreenshot.jpg&apos;,&apos;vs&apos;,&apos;width=870,height=640,toolbar=no,menubar=no&apos;) &quot;&gt;
&lt;img src=&quot;http://www.schierberl.com/cfblog/images/varScoperScreenshot_thumbnail.jpg&quot; border=&quot;0&quot; width=&quot;300&quot; height=&quot;220&quot; /&gt;
&lt;/a&gt;
				
				</description>
						
				
				<category>varScoper</category>				
				
				<category>coldfusion</category>				
				
				<pubDate>Thu, 20 Jul 2006 11:09:00 -0700</pubDate>
				<guid>http://www.schierberl.com/cfblog/index.cfm/2006/7/20/varScoper-10-release</guid>
				
			</item>
			
		 	
			</channel></rss>