pf » Top 10 Underrated Functions in ColdFusion

Top 10 Underrated Functions in ColdFusion

coldfusion

I gave a presentation at my local CFUG yesterday called 10 Underrated Functions in ColdFusion, I plan on doing one for tags as well at some point. Here was my list of functions, in no particular order:

  • ValueList - Returns the contents of an entire query column in a string list.
  • ExpandPath - Returns a server file path relative to the calling template.
  • Hash - Encodes a string using MD5, or in CFMX 7 you can specify any hashing algorithm such as SHA.
  • RandRange - Returns a random number bound by two integers.
  • XmlFormat - Escapes special characters in XML, and can also be used to prevent cross site scripting attacks.
  • IsValid - Validates that a string is in the specified format (email, ssn, integer, etc).
  • GetMetricData - Gives server metrics, like average request time, etc.
  • ToScript - Serializes a ColdFusion variable into JavaScript or ActionScript
  • GetPageContext - Gets the JSP PageContext object. Can be used to include JSP files in a CFM page, and more.
  • XmlSearch - Search an XML document using an XPath Query

Did I have any obvious omissions? What would be on your list?



Related Entries
This entry was:

Trackback Address: 617/982489622F899EEB937A1E033BFB3184
On 01/10/2007 at 9:05:04 AM MST todd sharp wrote:
1
There are a LOT of functions that I think are underrated - in fact, I think all built-in functions are overlooked at one point or another. I honestly have been meaning to re-read the function reference to remind myself of some of the gems out there.

On 01/10/2007 at 9:29:34 AM MST Brian Kotek wrote:
2
I'm always amazed whenever I see someone manually implement code to do what listQulify() or listChangeDelims() does.

On 01/10/2007 at 9:50:29 AM MST TJ Downes wrote:
3
IsValid() is one of the best functions ever

On 01/10/2007 at 9:54:23 AM MST Raymond Camden wrote:
4
A few:

incrementValue/decrementValue: If you don't need to keep the result, this is handy in urls, for example, linking ot the next page.

isDebugMode - add your own debug stuff (I need to blog this)

A big amen on isValid. I think it is probably the least known cool feature of CF7.

On 01/10/2007 at 9:54:32 AM MST Ryan Guill wrote:
5
ArrayToList() and ListToArray() would have to be one that I see implemented in other ways frequently.

On 01/10/2007 at 9:55:07 AM MST todd sharp wrote:
6
Brian - what about manual implementations of fileExists() or directoryExists()? I'm guilty of those (a long time ago ;)

On 01/10/2007 at 10:01:55 AM MST Sam wrote:
7
"I'm always amazed whenever I see someone manually implement code to do what listQulify() or listChangeDelims() does."

I'm even more amazed that I still do it from time to time =)

On 01/10/2007 at 10:09:49 AM MST todd sharp wrote:
8
Forgot to subscribe.

On 01/10/2007 at 11:12:00 AM MST JAlpino wrote:
9
They may not be under-rated but I find that val() and htmleditformat() are often overlooked in securing templates from incoming POST/GET data.

On 01/10/2007 at 11:19:10 AM MST Charlie Arehart wrote:
10
I'm with Brian on ListQualify. That's a hidden gem from 4.01 that it seems many missed (and continue to do). Great list, Pete. Thanks for sharing.

On 01/10/2007 at 11:25:57 AM MST todd sharp wrote:
11
What about urlEncodedFormat() and urlDecode() - I've seen manual workarounds to these before.

On 01/10/2007 at 2:45:42 PM MST Tjarko Rikkerink wrote:
12
Mine would probably be monthAsString in combination with setLocale(), coming from the Netherlands (in other words a non-english speaking/reading country) i still see a lot of developers making a list with the locale names of the months and then a loop with 1 to 12 and getting the correct name :-)

monthAsString(month(now())) would do the trick.. also for days. Much overlooked function. LSDateFormat(now(),'mmmm') would also do it.

On 01/10/2007 at 4:22:01 PM MST Oliver wrote:
13
XmlFormat() is kinda the suck, it does not parse xml all the time correct. I know its sloppy but I have been to busy to combine the 2 udf's but these in tandem will format anything in xml http://www.cflib.org/udf.cfm?ID=999 and http://www.cflib.org/udf.cfm?ID=572

On 01/10/2007 at 4:29:01 PM MST Pete Freitag wrote:
14
Oliver,

I'd love to see an example of where XmlFormat doesn't work. I haven't had any problems with it, not to say there aren't - I'd just like to see first hand.

On 01/10/2007 at 7:18:30 PM MST Ben Nadel wrote:
15
Just to go along with value list, there's the little used QuotedValueList() which does the same thing as ValueList() but puts quotes around each list item (like ListQualify() with quotes).

On 01/10/2007 at 7:48:25 PM MST Raymond Camden wrote:
16
xmlFormat is VERY broken. I've had numerous issues with it on BlogCFC where xmlFormat would let characters by (like MS Extended chars) that mess up valid XML.

On 01/11/2007 at 1:14:09 PM MST Oliver wrote:
17
Here is a link to a corrupt xml product feed, that used xmlFormat(). http://www.mothernature.com/xmlFormat_blows.xml. I will leave that example up for a week.

I had to use the udfs above xmlFormat2(xmlsafe()), lazy I know but it works.




  



Spell Checker by Foundeo





Subscribe to my RSS Feed: solosub RSS
Tags