All of us make rookie mistakes. I've always said it's best to learn from the successes and failures of others. One of my guys came to me earlier this week with one I had made myself a few years back. Something so simple, yet easily overlooked. Now, this guy has been writing ColdFusion for years, yet breezed right over it, assuming things acted one way when they acted completely another.
So, fairly simple, right? My guy expected REQUEST.base to be an empty string. But it wasn't. Why? Well, in an earlier part of the process was another cfparam tag:
The code in the first block was in a template that, in this case, was nested within another template (via cfinclude) that contained the second code block in it's head. So CGI.query_string was already assigned to REQUEST.base. What one has to remember is that, with cfparam, the default is only applied to the variable if the variable does not already exist. If the variable already exists, then the cfparam tag has no effect. Basically this is just like writing something like this:
<!--- The same as --->
<cfif not StructKeyExists(REQUEST,"base")>
<cfset REQUEST.base = "" />
Personally, I prefer the cfparam ;) (less code) Now, my guy was expecting an empty string, and was baffled as to why some other code wasn't processing properly. Once we sat down to dig in further, he saw that the value was not an empty string, and went about trying to figure out why it had a value. His confusion and frustration turned into anger over such a rookie hit, but everybody does it at some point.