2 Replies Latest reply on Jul 6, 2009 9:14 AM by josheby

    Passing Objects to Methods or Other Objects

    josheby Level 1

      I have a datasource object (cfc) that I have created and use.  During application startup I create the object at #application.datasource# and its then accessible to the entire application...


      I now have other compenents that need to use this object, but to keep my code modular, I do not want to reference #application.datasource# within my component, I want to pass the datasource object in as an argument.


      For example:


      <cffunction name="init" .... >

      <cfargument name="datasourceObject" type="struct".... />




      Then I would call it and pass application.datasource in as the value to the argument... but I have the feeling that I am passing a complete copy of that object in which is unneeded... is there a way to pass simply a reference?  so that if a change is made to the original application.datasource it would also be reflected within the components it was passed to?


      I figure this would save on over head as there will only be once copy of the object and the rest of the components will just reference that one...


      Any and all help would be appreciated!  Thanks!!