I haven't read this thread much... so I'll probably be repeating
things that others have already stated....
But, a "utility function" really best belongs in an object related to
the function. Patrick's example below is a perfect case in point. I
have really started looking at the Java core libraries for a pattern
when it comes to what we've always looked at as "utility functions."
There ought to be an HTMLObject base object, or a TextObject, that
handles formatting and so on. When you wish to expose the
functionality of that object to your model, you simply instantiate one
of them and use or extend it to avail your app of the tools.
I'm starting to think we need a standard set of ColdFusion core
CFCs... hey, a guy can dream!
J
On Apr 2, 2005 11:04 AM, Patrick McElhaney <[EMAIL PROTECTED]> wrote:
> 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
--
Continuum Media Group LLC
Burnsville, MN 55337
http://www.web-relevant.com
http://www.web-relevant.com/blogs/cfobjective
----------------------------------------------------------
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]