ColdFusion Muse

I'm a Cfcapricorn

I'm a Cfcapricorn

Ever so often an uber-geek Coldfusion programmer will ask me the question, "so.... what's your favorite Coldfusion tag?" It reminds me of a barfly asking "what's your sign". Nobody ever asks about my favorite CF function (I think I like "isValid( )" - very chic). As for my favorite tag, there are so many to choose from. Cfinvoke is a powerful, as is cfimport. Of course little actual work is ever done in CF without Cfquery. Cfcomponent and Cffunction earn high marks as well. But if you want to know my all time favorite tag I would have to say there are 2 tags that are more important and more useful than any other. In fact, I would say that the effective use of these two tags has made me into the Coldfusion Guru evangelist that I am today. If it wasn't for these 2 tags, people would not flock to my 72 Oldsmobile when I pull up at the quickie mart. I would not be able to afford that cubic zirconium ring I purchased for my lovely wife - and the Hottentots would just seem un-hot. Let me just step into the pulpit and tell you about them.

(Note: I've been sick and taking medication so please forgive me for the following)

Tag Number 1: Cfabort

Every day in every way Cfabort gets better and better. When an error raises its ugly head - cfabort. When a query is misbehaving - cfabort. When compilation causes agitation....when request execution causes disillusion... when a relocation destination causes consternation - cfabort. When you can't figure out why variable A is true and variable b is false and variable c does not exist in God's entire universe... I say unto you - Cfabort (can I get an Amen). Yes my friends... my brothers and sisters... Cfabort is not just a tag. It is not just some tag. Cfabort is the tag. It is the way to Cfsalvation (halleluiah!).

(Mopping brow) I am amazed... I am astounded... can I say I am flummoxed and even bamboozled (with apologies to Brother Malcolm) at the lack of understanding of this wonderful tag. How does anything get debugged without Cfabort. My friends, I have stood at the bedside of a dying CF application and watched as CF doctors try to bring it back to life and I can say to you without reservation that it cannot be done without the power of Cfabort. You can run requests over and over again. You can change form variables, recycle the services (except the 8:30 service - that one is kind of a holy cow around here), edit the database and even go so far as to rename the template... but until you Cfabort you are headed for destruction. So I say to you my dear friends and muse readers. Go forth and Cfabort. As you develop, add the tag at will and stop your executions. Examine your code and variables and learn what is happening within your request. Then you will know the meat and not just the milk of Coldfusion.

Now I must hasten to say that while Cfabort is a powerful tag - it must be used in conjunction with another, equally powerful tag. Without the 2 tags working together you will be like a football player without his pads, or a golfer without his clubs, or a rocket scientist without his... his ... head. No my friend, just Cfabort is not enough. You will also need - cfdump.

Tag Number 2: Cfdump

With Cfdump we can do more than just expect... we can introspect. We can do more than surmise. We don't have to compromise. We can see the inner workings of the most complex of objects. It could be a simple string or a mighty query or even (do I dare to say it) a immensely complex component - Cfdump can bring it to it's knees! Cfdump can handle java objects, Com objects, functions, and tags. It is the king of the debugging tags. It is the yin to the cfabort yang. Cfabort might plant the seed ... but it is cfdump that waters the seed and cfdump that provides the increase. Let us not dump upon fallow ground. Let us arise and go forth and dump the variables that cry out for dumping!

In All Seriousness

Actually, I really do use these 2 tags almost daily. I often participate in debugging sessions with novice and even intermediate to advanced Coldfusion programmers. I am continually astounded by the lack of understanding I see toward what is actually going on in a page. When facing new code for the first time I often start at the top of a template (or the application.cfm or even application.cfc file) and add aborts and dumps - working my way down to the meat of the application. This simple process tells me a great deal about what the page is supposed to do. When approaching a bug I sometimes work backwards, from where the bug occurs (if that can be determined) back to the beginning of the request. When troubleshooting components, I often interrupt a method call and dump out the state to see what is being passed in or about to be passed out.

Use the Debugging Information!!!

One more useful tip regarding debugging an application. I spend a good deal of time examining the debugging information so usefully provided by the CF server at the bottom of the page. This information can often tell you everything you need to know about bottlenecks and query results. My personal belief is that CF developers sometimes avoid the debug information and avoid Cfabort and cfdump because it "breaks" the page. Perhaps it's a legacy of so many of us coming from being web designers or HTML professionals. The debug and cfdump don't provide us with the "visual" result we are looking for. They seem like a step backward. But they are not a step back. They are, in fact an essential part of troubleshooting and debugging. Failing to use them will triple and quadruple the time it takes to debug a complex application (if you can debug it all).

So here's to Cfabort, Cfdump and the ugly debug info at the bottom of the page. Long may they live in our hearts and in our development - and may Ben Forta and Ray Camden bless our Cfefforts.

Comments
Jake Churchill's Gravatar AMEN!
# Posted By Jake Churchill | 12/28/07 7:06 PM
todd sharp's Gravatar Dude....Have you been invading my thoughts? I swear I already wrote this post (in my head). Very well said - I agree wholeheartedly. I can not tell you how many times I've helped beginners - but more importantly intermediate level programmers who don't abort, dump - or even look at the debugging information - or heck - even have debugging turned on!!! I'm going to cross blog this because I really think you're right on.

Oh... you get minus one point for this disgusting CAPTCHA on this comment form.
# Posted By todd sharp | 12/28/07 7:40 PM
Sean Corfield's Gravatar I never use cfabort because it stops execution of the program and if you picked the wrong place, you have to edit the code and run your tests again and rinse and repeat.

I use cfdump - and output="console" so I can watch what's going on in the console log while the program runs. Very useful. Yes, new in CF8.

I use cflog - with log="console" - again so I can watch my debugging while the program is running.

I use cftrace quite a bit too.

And of course there's the ColdFusion 8 step debugger.
# Posted By Sean Corfield | 12/28/07 11:18 PM
Ben Nadel's Gravatar Mark - funniest post ever :) And right on the money. CFDump / CFAbort are the greatest duo to hit the CF debugging scene. And sometimes, when I'm feeling really randy, I get hot and steamy with this little ménage à trois:

<cfdump var="#query#" />
<cftransaction action="rollback" />
<cfabort />

This is handy when a lot of inserts are taking place.
# Posted By Ben Nadel | 12/29/07 10:51 AM
Sean Corfield's Gravatar Mark contacted me privately to ask if I found the post funny and on reading it again, I still don't, so I can only assume there's some American cultural references here that I'm missing?

Ben's comment makes it clear that *something* is supposed to be funny here. Can someone explain to a Brit what Mark is parodying? (or what the cultural reference is)
# Posted By Sean Corfield | 12/29/07 12:55 PM
Ben Nadel's Gravatar @Sean,

I don't know what / if Mark is parodying anything in particular, but what jumps to mind for me are things like Sam Kinison and movies like, Coming To America in which Arsenio Hall plays Reverend Brown:

Now'ah, some people say that loving the Lord is wrong. Well'ah, if loving the Lord is wrong, well then'ah, I don't wanna be right - can I get an ahmen!

In America, we have a whole host of movies that parody the overly zealous preacher types; so, that could be a cultural thing.
# Posted By Ben Nadel | 12/29/07 1:06 PM
Gareth's Gravatar @Ben,
Yeah, not a lot of deep south preachers over in the UK :)
# Posted By Gareth | 12/29/07 5:06 PM
Mike Kelp's Gravatar "And the lawd came down as the sheppard amongst us sheep."

If only I could do the voice haha. Anyway, I feel the same way about these tags as you do, but your post makes me want to say:
# Posted By Mike Kelp | 12/30/07 12:00 AM
Raymond Camden's Gravatar I think Sean makes a very good point. As much as I love the cfdump/cfabort dance (normally when I write a UDF version of cfdump, for use w/n cfscript, I include an option to abort as well), it does stop page execution and isn't as useful when doing flash remoting or other 'remote' work. In that case, the options Sean mentions are much better alternatives.

Sean - I think you should write up a quick blog entry on debugging suggestions that _don't_ involve the normal cfdump/cfabort procedure.
# Posted By Raymond Camden | 12/30/07 10:01 AM
mark kruger's Gravatar Sean,

The paradoy is actually of a gospel service - of the variety you find black churches or pentecostal churches (or sometimes charismatic churches) here in America. I grew up in a pentacostal church and I was a pastor for 9 years... so this sort of thing is in my roots :) Things like the references to "brothers and sisters" and "mopping my brow" and the stacato incantation of similar sounding words (.. relocation destination causes consternation) bring to mind a preacher "winding up" his delivery and whipping the congregation into a fever pitch.

It's not meant to make fun of such churches - more like an endearing homage to them :)
# Posted By mark kruger | 12/31/07 9:21 AM
Sean Corfield's Gravatar Thanx for the explanation. Definitely not something familiar to a Brit (especially a Brit who never went to church).
# Posted By Sean Corfield | 12/31/07 9:30 AM
Susan's Gravatar If only I could do the voice:funny
# Posted By Susan | 7/2/08 7:38 AM



Blog provided and hosted by CF Webtools. Blog Sofware by Ray Camden.