Quantcast
Channel: The Creative Juices Bo. Co. (CJBoCo) RSS 2.0 Feed
Viewing all articles
Browse latest Browse all 130

ColdFusion Tips & Tricks: Components (Blog Entry)

$
0
0

ColdFusion Components and Var Scoping Trick

Var scoping is essential when dealing with ColdFusion Components. You can get weird results or even some hard-to-track errors if you don't do this. I'm not privy as to why this happens, I just know that it does. It's one of those mysteries that I just never bothered to research. All I know, is that sometimes it's a pain in the butt, especially when your writing a fairly complex function and you forgot to var scope an "i" in a cfloop or some other quick and dirty variable you made.

Well a few months back, I started doing something with my function variables, that I thought I would share. Not only does it solve my var problem, but it winds up making the top of my function shorter (I'm a stickler for cleanish looking code). Essentially I create a generic local struct in the begining and I'm sure to var scope it, like so:

<cfset var local = StructNew() />

Viewing all articles
Browse latest Browse all 130

Trending Articles