I see ... those are excellent reasons. I'm not entirely clear on CFCs, but nothing that I am writing is large enough for me to do that with I think. I have a bunch of little code time savers like this:
<cffunction name="getRandomString" output="no" returntype="string">
<cfset chars = "0123456789ABCDEFGHIJLKMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" / >
<cfset randout = "">
<cfset stringLength = "30">
<cfloop from="1" to="#stringLength#" index="i">
<cfset rnum = ceiling(rand() * len(chars))>
<cfif rnum EQ 0 >
<cfset rnum = 1 / >
</cfif>
<cfset randout = randout & mid(chars, rnum, 1)>
</cfloop>
<cfreturn "#randout#">
</cffunction>
Perhaps they should all go in a CFC called something like UDF.CFC. I believe that I can call one of several functions in a CFC. I'm not clear on if a CFC is ONE process or can be a collection of processes. I'm also not clear on where to put it so that it can be accessed by all pages in a site.
I appreciate your comments, they are really helping my understanding of ColdFusion.
| I have a bunch of little code time savers |
You could always use an include, of course. You should be thinking about CFCs when some functions share themes in common, when functions become complex or when the number of functions becomes large.
| Perhaps they should all go in a CFC called something like UDF.CFC. |
Yes, they could go into a CFC, but not necessarily all in one CFC. You should group functions together only if they express the behaviour of one particular concept. For example, you could make functions that manipulate strings, like getRandomString, part of StringManipulation.cfc.
| I believe that I can call one of several functions in a CFC. |
You can call any number of functions from a CFM page or from a function in another CFC.
| I'm not clear on if a CFC is ONE process or can be a collection of processes. |
A function call by means of an instance of a component, as follows, is one process
<cfset obj = createobject("component", "dotted.path.to.comp")>
<cfset theVar = obj.func()>
However, there are ways to create two or more such processes to run at the same time.
| I'm also not clear on where to put it so that it can be accessed by all pages in a site. |
As Dan has said, you can put it within or outside the wwwroot folder. The important thing is to distribute your CFMs and CFCs into folders in such a way that your application will have a logical, easy-to-follow structure.