Yes, there is overhead.  No, I don't think you're doing anything
harmful.  Obviously if the get method are doing anything complex, you
might be better off calling them once, but the extra method call
itself shouldn't affect performance in a noticable way.

Careful load testing is the only way to be sure, of course, but I've
never had issues chaining getters like that with CFCs.

cheers,
barneyb

On Wed, 15 Dec 2004 17:00:35 -0500, Ken Dunnington
<[EMAIL PROTECTED]> wrote:
> I'm rebuilding a newsletter system, and using it as a learning
> experience in OO. I've already made some fundamental design changes,
> which worked out to comparably small code changes (I haven't built the
> database yet, mind you) and things are generally going well. One of
> the things I'm doing is abstracting various parts of the model when
> they need to be called in other parts. For example, my
> newsletterManager class acts as a service locator to the application
> for the other manager classes, each of which controls access to my DAO
> and gateway objects. So, my question is, when I need to make multiple
> method calls to one of these objects, is there any advantage to
> creating a local reference to the object within my method, or is it
> purely aesthetic?
> 
> Here's an example (since I'm sure I didn't explain that well :)):
> 
>        <cffunction name="send" returnType="void" output="false" 
> access="remote">
>                <cfargument name="newsletterID" type="numeric" required="yes" 
> />
>                <cfset var newsletter = getDAO().read(arguments.newsletterID) 
> />
>                <cfset var text = getGateway().getTextArray(newsletter) />
>                <cfset var images = getGateway().getImageArray(newsletter) />
>                <cfset var template =
> getTemplateManager().getDAO().read(newsletter.getTemplate()) />
>                <cfset var list = 
> getSubscriptionManager().readList(newsletter.getList()) />
>                <cfset var userList = 
> getSubscriptionManager().getUsersInList(list.getID()) />
> ...etc.
> 
> Now, would it be better to create a reference like this: <cfset var
> dao = getDAO() /> and then call methods on that? Or, since I'm merely
> referencing objects which are declared within the newsletter object
> anyway (the DAO's, gateways and managers are passed in to the
> newsletterManager on construction,) should I use the original
> reference, which is 'variables.instance.dao' etc.?
> 
> I suppose a better way to ask this is, is the way I'm doing it
> actually harmful because of unnecessary method calls?
> 
> - Ken
-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/blog/
----------------------------------------------------------
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 
[EMAIL PROTECTED]

Reply via email to