It might get confusing, but you could use dot notation for the file and
function (file.function).

To make it less confusing (by enforcing strict rules) you might have CF
match this first by directory, then by file name, then by function.

So "dir.file.function" would find the UDF "function" in the library
"file" in the directory "dir".

If you had a file named "dir" at the root, too bad.

This would of course happen at every level (search down from directory,
file, function) so you could have large names like
"dir.dir1.dir3.file.function"

Some simple management would make conflicts dissappear.  In most cases
folders represent apps or domains and using a file naming standard
(something like "Lib_These functions" or "Functions_Lib") would
eliminate conflicts with function names.

In the end the problem is only slightly more complicated that that
already faced by people using dot notation in the CustomTags directory.

To make things a little easier you might also allow for aliasing of some
kind.  For example a declaritive system (which I think might work better
in CF) might have a tag like:

<cfalias type="UDF" alias="MyFunction"
realname="dir.dir1.dir3.file.function">

Such as alias tag could be modified (slightly) to also alias CFCs,
Custom Tags, perhaps even templates (this could be nice... ).

Another option might be something like:

<cfsetalias MyFunction = dir.dir1.dir3.file.function()>

But that's not as clear, I think.

Just some thoughts.

Jim Davis

> -----Original Message-----
> From: Christian Cantrell [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 01, 2003 6:01 PM
> To: CF-Talk
> Subject: Re: Some idea about the Efficiency of UDFs
> 
> 
> Interesting idea.  So how exactly would this work?  Would ColdFusion
> expect one function per file, with the requirement that the file and  
> the function have the same name?  Then you could call any arbitrary  
> UDF, and the CF server would look in the proper directory for 
> the right  
> file, then execute the function in that file.  How else could 
> this work?
> 
> Let's flesh it out a bit here, then I invite you to submit
> your idea to  
> Macromedia at the following URL:
> 
> http://www.macromedia.com/support/email/wishform/?6213=3
> 
> Christian
> 
> On Wednesday, January 1, 2003, at 04:40 PM, Li Chunshen ((Don)) wrote:
> 
> > According to Macromedia's CFMX References on Using
> > UDFs effectively:
> >
> > "Consider the following techniques for making your functions 
> > available to your ColdFusion pages:
> >
> > If you consistently call a small number of UDFs,
> > consider putting their definitions on the
> > Application.cfm page.
> > If you call UDFs in only a few of your application
> > pages, do not include their definitions in
> > Application.cfm.
> > If you use many UDFs, put their definitions on one or
> > more ColdFusion pages that contain only UDFs. You can include the 
> > UDF definition page in any page that calls the UDFs. "
> >
> > I agree with everything it states, and I think it
> > might help more if CFMX predefines a UDF library path
> > such as UDFlib under CFMX installation instead of an arbitrary
> > directory, I can see several benefits of this approach:
> > consistency -- especially helpful for large
> > development environment;
> > easier for reuse -- across applications/projects
> > (this one is similar to CFMODULE's dot notation
> > method, I love it)
> >
> > And I don't see any downside of it.  Thanks.
> >
> > DL
> >
> >
> > --- Matthew Walker <[EMAIL PROTECTED]> wrote:
> >> These two cfmx UDFs from cflib.org may help:
> >>
> >>
> >> <cfscript>
> >>    function DSNExists(DSN) {
> >>            var factory =
> >>
> > createObject("java","coldfusion.server.ServiceFactory");
> >>            var DSNs =
> >> factory.getDataSourceService().getNames();
> >>            return
> >> yesNoFormat(listFindNoCase(arrayToList(DSNs),
> >> DSN));
> >>    }
> >> </cfscript>
> >>
> >>
> >> <!---
> >>  Verifies a DSN is working.
> >>
> >>  @param dsn         Name of a DSN you want to verify.
> >> (Required)
> >>  @return Returns a Boolean.
> >>  @author Ben Forta ([EMAIL PROTECTED])
> >>  @version 1, October 15, 2002
> >> --->
> >> <CFFUNCTION NAME="VerifyDSN" RETURNTYPE="boolean">
> >>    <CFARGUMENT NAME="dsn" TYPE="string"
> >> REQUIRED="yes">
> >>
> >>    <!--- initialize variables --->
> >>    <CFSET var dsService="">
> >>    <!--- Try/catch block, throws errors if bad DSN
> >> --->
> >>    <CFSET var result="true">
> >>
> >>
> >>    <CFTRY>
> >>       <!--- Get "factory" --->
> >>       <CFOBJECT ACTION="CREATE"
> >>                 TYPE="JAVA"
> >>
> >> CLASS="coldfusion.server.ServiceFactory"
> >>                 NAME="factory">
> >>       <!--- Get datasource service --->
> >>       <CFSET
> >> dsService=factory.getDataSourceService()>
> >>       <!--- Validate DSN --->
> >>       <CFSET result=dsService.verifyDatasource(dsn)>
> >>
> >>       <!--- If any error, return FALSE --->
> >>      <CFCATCH TYPE="any">
> >>         <CFSET result="false">
> >>      </CFCATCH>
> >>    </CFTRY>
> >>
> >>    <CFRETURN result>
> >> </CFFUNCTION>
> >>
> >>> -----Original Message-----
> >>> From: Li Chunshen (Don) [mailto:[EMAIL PROTECTED]]
> >>> Sent: Wednesday, 1 January 2003 11:37 a.m.
> >>> To: CF-Talk
> >>> Subject: Request Time
> >>>
> >>>
> >>> specs: CFMX on WinXP Pro; remote datasources on
> >> Win2k
> >>> Pro.
> >>>
> >>> Requestimeout set to 40 seconds via CF admin
> >> (server
> >>> has been rebooted, my friend).  Expect cf server
> >> to
> >>> throw requestimeout msg, better, gracefully,
> >>> regardless of the types of request.  Problem, when
> >>> trying to connect to an unavailable remote
> >> datasource
> >>> (who can garanttee it's always available?),
> >> instead
> >>> of 40 seconds timeout, CFMX keeps on trying and
> >> trying
> >>> though asked otherwise, what's going on?  With
> >> CF5, an
> >>> undocumented tag of Is_CFdatasource takes care of
> >> the
> >>> problem very well.  Thanks.
> >>>
> >>> DL
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> __________________________________________________
> >>> Do you Yahoo!?
> >>> Yahoo! Mail Plus - Powerful. Affordable. Sign up
> >> now.
> >>> http://mailplus.yahoo.com
> >>>
> >>
> >
> > 
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

Reply via email to