One question to consider about placement is variable scoping. UDFs follow CF rules for variable scopes.

There are 4 possibilities to consider.
   - request scope - current request thread - starts with Application.cfm
   - include scope - include files themselves
   - cfc scope - object library
   - template scope - current executing template

Other scopes like session and application may be considered as well, but this 4 are the most related to runtime functions.

There is no fixed rule as to what possibility is best. The choice really depends on the application for runtime and support considerations.

CFCs do make programming with UDFs much easier, especially being able to use object notation. For example,
/framework/udf.cfc could be for those common UDF that are scope insensitive. Suppose there is a udf.cfc function called, makechoice(varvalue1, varvalue2, stringtrue, stringfalse ) that compares two variable values and returns one string or the
other depending on the comparison.


Then in the application, code something like:
<cfparam name="form.optin" default="0">
<cfinvoke component="framework.udf" returnvariable="udf" />
<input type="checkbox" name="form.optin" value="1" #udf.makechoice(form.optin, "1", "checked", "")# >


This code is much easier to understand and maintain.

When to do the cfinvoke? This is a "cost" question. CF offers different coding options here again. The CFC can be instanced or transient. The programming decision is when and how to spend the execution resources. Once again the main consideration is the application itself.

Joseph


At 08:38 AM 6/1/2004, you wrote:
Well I placed all my UDFs in a central CFC that all my other CFCs extend. This practice makes sense to me but I do not know if it is the best way to go about it.


On Jun 1, 2004, at 10:22 AM, Dawson, Michael wrote:

If possible, I would put the functions in a CFC, then store the CFC in
the Application scope.  That would keep them in memory.

If you have other CFCs that might use the UDF CFC, you can pass a
reference to the necessary methods.

<cfset Application.Functions = CreateObject("component", "UDFs")>

...then...

<cfset myReturnVar = myMethod(Application.Functions, "myOtherArg")>

M!ke

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]


------------------------------------------
Switch_box
www.Switch-box.org
MediaFirm, Inc.
PO Box 2171
Loveland, CO 80539

[EMAIL PROTECTED]

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to