That does seem like good encapsulation.
How would I go about doing that? Would I need to do that in my init method? If so, does this also limit my ability to use a method without first instantiating the component. Again, I am not married to that approach it just seems handy for rarely used methods in rarely used objects.
If using cfinvoke as I am is a bad practice, I would certainly like to understand when it should be used so that I can adjust my practices accordingly. I would also like to understand the performance implications of instantiating the object every time. Am I worrying about that for nothing? I am expecting the site to be pretty high-traffic so I am abnormally concerned with performance.
Thanks and sorry for all of the question!
Steve
At 08:33 PM 9/29/2004, you wrote:
Steve,
Although I am not an OO or good design guru and someone might guide you a better design decision however what about having all your dsn variables i.e dns name, username, password etc as an instance variable of a DAOConstants cfc.. For all other CFCs in your model you can essentially composite this DAOConstants cfc and get those variables by calling the getter method on your contants CFC. Hope it helps
Qasim
On Wed, 29 Sep 2004 20:19:38 -0500, Steve Bryant
<[EMAIL PROTECTED]> wrote:
> 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
>
> At 07:35 PM 9/29/2004, you wrote:
> >You are, of course, free to do whatever you like. But encapsulation has
> >a huge history of benefits and I'm afraid your opinion isn't going to
> >put the slightest dent in that history.
> >
> >In your example, I would argue that you should indeed be passing the CGI
> >variable into the CFC and not calling it directly. There's absolutely no
> >reason to do call it directly, the "cost" of passing it in is miniscule,
> >but the benefits of well-encapsulated code are thoroughly confirmed. The
> >same applies to calling request-scoped UDF's from within a CFC: it's
> >totally unnecessary. In fact, why are the UDF's in the request scope
> >anyway? I'd say, move them into an object and call them through the
> >object. If another CFC needs to use them, I'll pass in the object.
>
> ----------------------------------------------------------
> 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]
>
----------------------------------------------------------
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]
----------------------------------------------------------
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]
