I think the latter is much more readable, since it clearly separates
distinct operations.  If they were all one large operation (which is a valid
argument for calling numerous setters, among other things), then I'd much
prefer to see a general method that performs the operations as a block (a
setAll() type method).

Not chaining also removes the ambiguity of "what is doMethod() returning".
I only chain when doMethod() returns something DIFFERENT from the object
it's a member of.  Something like this:

  myList.get(index).getName();

Finally the ability to do chaining depends on the author of the original
object returning a referece to this from all the methods.  That seems a
rather fickle thing to base a 'standard' way to do things on, so I prefer to
not require that assumption to make all my code formatted consistently.

Sean Corfield prefers chaining, and so his coding guidelines undoubtedly
recommend that as the proper way to do it (I haven't read them).  I suspect
that that's a stong motivating factor in the adoption of the syntax, for
good or bad, since those guidelines are well respected in the CF community.
Personally, I applaud people for taking the time to read, digest, and apply
his coding guidelines in their own code.  Clear, consistent code is better
than messy code, syntactic idiosyncracies aside.

barneyb

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Matt Liotta
> Sent: Monday, October 06, 2003 12:27 PM
> To: [EMAIL PROTECTED]
> Subject: [CFCDev] Method chaining overhead
>
>
> I have noticed a number of people using syntax like the following with
> there CFCs.
>
> cfc.doMethod().doAnotherMethod();
>
> As opposed to...
>
> cfc.doMethod();
> cfc.doAnotherMethod();
>
> While it is certainly debatable as to which is better from a stylistic
> point of view, I wonder if there is more overhead associated with the
> first technique. Here's my thought, since the first technique requires
> the method to return a value it has slightly more overhead than a
> method that doesn't. I don't know if that is actually true, but
> anecdotally it seems as such. While I don't claim to know the internals
> of CFMX, it seems that it has some casting overhead sometimes when it
> returns data from a method.
>
> Thoughts?
>
> Matt Liotta
> President & CEO
> Montara Software, Inc.
> http://www.MontaraSoftware.com
> (888) 408-0900 x901
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word '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 word '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