Skip to main content
March 12, 2009
Question

Method Chaining

  • March 12, 2009
  • 1 reply
  • 307 views
Hi, this isn't really a question as such, but I wondered your opinions on method chaining in ColdFusion. Is this normal practice?

I have a CFC which I use like so

<cfset variables.wow = application.item />
<cfoutput>#variables.wow.getItem(1).getField("title")#</cfoutput>

I like this style of syntax, but can anyone highlight any performance issues this kind of syntax might have or anything else for that matter? To get this to work, the getItem function must return THIS for example.

Cheers,
Mikey
    This topic has been closed for replies.

    1 reply

    Inspiring
    March 12, 2009
    It is common and you seem to understand the requirement of returning the
    object (THIS) in any function that is chained for chaining to work.

    So, if you like it, go for it. That is one of the things I appreciate
    about ColdFusion it is very flexible and lets you develop the way you
    like, not forcing any particular style or methodology down ones throat.