methods/functions and data about your users (name, log-in time, etc) then
the choice is clearly CFCs. If you only plan to persist functionality and
not data then functions seem more appropriate.
However - and this is arguable to the Nth - CFCs do make for damn nice
function library wrappers. No - they're not "supposed" to be used for that
and some people would have my thumbs for suggesting it but.
1) Once you create the CFC you can instantiate all the functions within it
with a single line of code.
2) That single line of code can also persist the functions - with UDFs you
must assign the UDFs individually to the persistent scope.
3) A CFC can be named anything. So you can more easily distribute it
without requiring firm naming conventions. With a UDF library you have to
either distribute the function with instructions for how to persist each
function or assume a standard name (and scope) such as
"request.mylib.myfunction".
4) Related to 3) is the concept that even tho a CFC-based library can be
named anything you can still call other library functions internally with no
knowledge of the named used by the hosting application. With UDFs you're
really forced to set the name/scope of the function to have any cooperation
among them.
In short the more I think about it the more I like persistent CFCs as
function library wrappers. I'd be interested in hearing other opinions on
this.
Jim Davis
_____
From: Michael Dinowitz [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 08, 2004 12:31 AM
To: CF-Talk
Subject: CFCs vs. CFFUNCTIONs
While describing a methodology I'm using for a project, Dave Watts asked a
very interesting question. The methodology was to cache a number of CFCs in
the application scope and store user information (that will be used by the
CFCs) in the session scope. Dave's question was basically "why make them
CFCs? Why not just make them all CFFUNCTIONs?"
Take for example a Users CFC which contains all of the functions for user
login, logout, information, etc. A single cached CFC could do it or a host
of CFFUNCTIONs that are included inside a single CFINCLUDE. A third option
would be to cache each CFFUNCTION into the application scope for use.
These are all interesting approaches. What are peoples thoughts on these?
Does one look better than the other? Faster? More optimal?
_____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

