John,

I thought about this approach, but it wouldn't (unless I am missing something) allow me to use the method in a component that I am invoking without ever having instantiated it and called the init() function. If it is bad practice to do so, I am willing to accept that, but then it seems that I am incurring a performance hit for something I only intend to use on that page once.

I want encapsulation, but I am not sure if the cost is worth the reward in that case. Again, I expect that I am missing something.

Steve

At 08:35 PM 9/29/2004, you wrote:
Steve... what many of us do is just create an "INIT" function that you use
when creating the CFC instantiation. Pass the DSN into the init call when or
immediately after creating it. (assign it to variables.dsn ... or something
like that to make it available to all the functions of the CFC.) That should
get you where you want to go.

John Farrar
SOSensible

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Steve Bryant
Sent: Wednesday, September 29, 2004 9:20 PM
To: [EMAIL PROTECTED]
Subject: [CFCDev] Encapsulation and Request vars (was Function Libraries)

I have a practical question to bring to this little discussion.

I am currently coding my first site which makes large-scale (for me) use of
CFCs. Most of these CFCs access the database for the site. I am currently
using a request variable to store the datasource. I am not doing this
because I don't believe in the value of encapsulation, but rather because I
can't figure out a better way to handle it.

I don't want to pass the datasource in to each and every method. I don't
want to incur a bunch of overhead in getting the datasource for query in
every method. I do want to be able to invoke some methods (via cfinvoke)
without first instantiating the object.

I am certainly missing some good practice of which others are aware. I
would love to be enlightened.

Thanks All!

Steve


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to