On Apr 1, 2005 1: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.
I don't think utitilty functions have any place in an object-oriented
application. Instead, consider replacing all of your utility functions
with objects. For example, you might have CFC that knows how to take a
string and make it HTML friendly.
<cfset formatter = createObject("component", "HTMLFormatter").init()/>
<cfset htmlFriendlyString = formatter.format(originalString)/>
I know, technically that's just a utility function wrapped in its own
CFC. But you can instantiate the CFC and use the function from
anywhere in the application. And you get all of the benefits of OO.
* You can choose the implementation at runtime using polymorphism.
* You can set properties on the object once instead of passing the same
arguments to the function many times.
* You can add responsibilies by subclassing or "decorating" the object.
* You can make the function available to other applications by simply
copying a file.
HTH,
Patrick
--
Patrick McElhaney
704.560.9117
http://pmcelhaney.weblogs.us
----------------------------------------------------------
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]