Skip to main content
Participant
October 1, 2013
Question

Instantiating objects in cfc (CF9)

  • October 1, 2013
  • 2 replies
  • 529 views

Hi all,

in certain cases it is necessary to me to instantiate objects like this:

<cfcomponent...>

<cfset this.myObj = new myCFC() />

<cffunction...>

some code

</cffunction>

</cfcomponent>

I think to remember that I've read recently that this kind of instantiating isn't recommended. So I just wanted to ask the veterans about it.

Mostly I use this way in cases where recursion are used so I do not need to reinstantiate the objects with each recursive call of a function.

Thanks in advance

Hurga

    This topic has been closed for replies.

    2 replies

    Participating Frequently
    October 1, 2013

    Can't see your code.  Can you edit your question?

    Participant
    October 1, 2013

    Oh, sorry...there is no edit button.

    Here it is:

    <cfcomponent...>

    <cfset this.myObj = new myCFC() />

    <cffunction...>

    some code

    </cffunction>

    </cfcomponent>