I organize my functions in libraries and load the libraries with a custom
tag. Each library is just a file with a collection of UDFs. All the
libraries are within a single directory.
When I need access to one or more UDFs, I call a custom tag that includes
the library and places the named functions in the specified scope. The
default scope is "caller".
<cfmodule template="tagLibs/function/loadLibrary.cfm" library="file"
scope="variables" functions="directoryDelete,directoryMove" />
That will load the directoryDelete and directoryMove UDFs into the caller's
"variables" scope.
In reality, my code usually looks more like this:
<cfmodule template="tagLibs/function/loadLibrary.cfm"
library="file,encoding,string" />
That loads all the UDFs in the file, encoding and string libraries into the
caller's "variables" scope. This method avoids dependency issues (i.e. some
UDFs in a library may use other UDFs in that library).
This technique also works for loading library functions into a component's
instance "variables" scope:
<cfcomponent output="no">
<cffunction name="init" output="no">
<cfmodule template="tagLibs/function/loadLibrary.cfm"
library="numeric" >
</cffunction>
</cfcomponent>
And it works with the local function "unnamed" scope:
<cfcomponent output="no">
<cffunction name="myMethod" output="no">
<cfset var local = structNew()>
<cfmodule template="tagLibs/function/loadLibrary.cfm"
library="numeric" scope="local">
</cffunction>
</cfcomponent>
As mentioned above. There are a few instances in which dependency issues
arise. Usually, this can be avoided by reworking the UDFs a bit, but that's
not always the case. The only way to be sure that there are no dependency
issues is to load all of the UDFs from one library into the "variables"
scope.
Ben Rogers
http://www.c4.net
v.508.240.0051
f.508.240.0057
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of Aaron Rouse
> Sent: Friday, April 01, 2005 10:56 PM
> To: [email protected]
> Subject: Re: [CFCDev] Where to put 'utility' functions?
>
> I too would be curious how people address this.
>
> On Apr 1, 2005 12:05 PM, Adrocknaphobia <[EMAIL PROTECTED]> wrote:
> > Unicode functions aside, does anyone have an answer to his original
> > question on how to organize untility functions better? Being that you
> > can only extend one cfc and we dont have a import option, are we left
> > at loading utility cfcs in the init? (ie. on init() the utility cfc's
> > methods are copied into the base cfc.
> >
> > -Adam
> >
> > On Apr 1, 2005 12:54 PM, Ken Dunnington <[EMAIL PROTECTED]>
> wrote:
> > > I will try that, thanks! I knew about the useUnicode flag's existence,
> > > but I never actually knew where it went. :) I'll post the results
> > > later.
> > >
> > > On Apr 1, 2005 11:35 AM, Tim Blair <[EMAIL PROTECTED]> wrote:
> > > > Ken,
> > > >
> > > > > I've read many posts on this list about the subject, but haven't
> had
> > > > > any luck - I still get mojibake even with cfprocessingdirectives,
> > > > > cfcontents, and setEncodings in place.
> > > >
> > > > Can you output the characters pulled from the database properly
> using
> > > > HTML? I'm not sure about the unicode handling of Flash, but you
> could
> > > > try the following and see if you have any joy:
> > > >
> > > > When setting up your datasource in CFAdmin click the "show advanced
> > > > settings" button, and in the connection string box put the
> following:
> > > >
> > > > useUnicode=true&characterEncoding=UTF-8
> > > >
> > > > Note: This string is case sensitive! That should encode anything
> going
> > > > in and out, but any existing data won't be stored in the correct
> format
> > > > so you'll still get dodgy chars pulling it back out. BTW, if you're
> > > > worried about it not working on MySQL 4.0 -- we're still using 3.23
> on a
> > > > couple of servers and the above works absolutely fine!
> > > >
> > > > Any good?
> > > >
> > > > Tim.
> > > >
> > > > --
> > > > -------------------------------------------------------
> > > > Badpen Tech - CF and web-tech: http://tech.badpen.com/
> > > > -------------------------------------------------------
> > > > RAWNET LTD - independent digital media agency
> > > > "We are big, we are funny and we are clever!"
> > > > New site launched at http://www.rawnet.com/
> > > > -------------------------------------------------------
> > > > This message may contain information which is legally
> > > > privileged and/or confidential. If you are not the
> > > > intended recipient, you are hereby notified that any
> > > > unauthorised disclosure, copying, distribution or use
> > > > of this information is strictly prohibited. Such
> > > > notification notwithstanding, any comments, opinions,
> > > > information or conclusions expressed in this message
> > > > are those of the originator, not of rawnet limited,
> > > > unless otherwise explicitly and independently indicated
> > > > by an authorised representative of rawnet limited.
> > > > -------------------------------------------------------
> > > >
> > > > ----------------------------------------------------------
> > > > You are subscribed to cfcdev. To unsubscribe, send an email to
> [email protected] with the words 'unsubscribe cfcdev' as the subject of
> the email.
> > > >
> > > > CFCDev is run by CFCZone (www.cfczone.org) and supported by
> CFXHosting (www.cfxhosting.com).
> > > >
> > > > An archive of the CFCDev list is available at
> > > > www.mail-archive.com/[email protected]
> > > >
> > > >
> > >
> > > --
> > > It's a metaphor for life itself. For that matter, everything in life
> > > is a metaphor for life. Except life. Life is probably a metaphor for
> > > metaphor. -- James Lileks
> > >
> > > ----------------------------------------------------------
> > > You are subscribed to cfcdev. To unsubscribe, send an email to
> [email protected] with the words 'unsubscribe cfcdev' as the subject of
> the email.
> > >
> > > CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
> (www.cfxhosting.com).
> > >
> > > An archive of the CFCDev list is available at
> > > www.mail-archive.com/[email protected]
> > >
> > >
> >
> > ----------------------------------------------------------
> > You are subscribed to cfcdev. To unsubscribe, send an email to
> [email protected] with the words 'unsubscribe cfcdev' as the subject of
> the email.
> >
> > CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
> (www.cfxhosting.com).
> >
> > An archive of the CFCDev list is available at
> > www.mail-archive.com/[email protected]
> >
> >
>
>
> --
> Aaron Rouse
> http://www.happyhacker.com/
>
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email to
> [email protected] with the words 'unsubscribe cfcdev' as the subject of
> the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
> (www.cfxhosting.com).
>
> An archive of the CFCDev list is available at
> www.mail-archive.com/[email protected]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]