ColdFusion Markup Language (CFML) is made up of tags and functions. The prior two chapters reviewed the ability to create your own tags; this chapter reviews creating your own functions. User-defined functions (UDFs) are just that: functions you create for use in your own applications. UDFs are similar to custom tags in that they allow developers to encapsulate tried-and-true functionality for the reuse of code throughout and between ColdFusion applications.
Visit http://www.cflib.org to browse and download the most extensive public UDF libraries. Unlike Custom Tags, which are created using tags, UDFs can be created using tags and <cfscript>. Any CFML code can use UDFs, regardless of how they are written. The big difference between tag- and <cfscript>-based UDFs is what they can do (<cfscript> is limited in that it cannot execute tags). NOTE The only advantage of <cfscript>-based tags is that they are sometimes easier to port to and from other languages (like JavaScript and ActionScript). |