Ok, I think you guys have really missed the mark on the question. I'm
begining to think that any question asked on this list is a test of
your associative knowledge of how can you provide the same answer to
every question. ie OO.

So I have 5 functions that are very handy when working with Oracle.
And I have 5 functions that do something so amazing I cannot begin to
explain. Now, both are encapsulated as CFCs. Wonderful! OO for the
sake of it right? Well like other languages I would like to 'import'
these functions into another CFC.

Right now, during the init() of the main CFC I'm loading oracle.cfc
and copying the methods to the base cfc and so forth for any other
imports I'd like to do. Problem is that this is not very elegant. So
back to the main question at hand... does anyone have any other
solutions that they would like to share? The only other option is to
extend these utlility cfcs in some sort of mind numbing chain of
complexity using... extends. Which, by the way, really sucks and
limits you from actually using extend properly.

So... now that I have explained all this a lightbuild has gone off in
my head. (A dim one at best, more like a xmas light) Couldn't I just
write an import() function where only the classpath was an argument.
Then place that function in the coldFusion cfc class or whatever you
call it (The one that will add those functions to every cfc). Then
outside of my init() in the magical space between <cfcomponent> and
the first <cffunction> I could simply put:

<cfcsript>
import(com.adrocknaphobia.util.oracle);
import(com.adrocknaphobia.util.handofgod);
</cfcsript>

Is this destined for failure? or might just work?

-Adam


On Apr 2, 2005 4:09 PM, Jared Rypka-Hauer - CMG, LLC <[EMAIL PROTECTED]> wrote:
> 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]
> 
>


----------------------------------------------------------
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]


Reply via email to