4 Replies Latest reply on May 30, 2006 10:38 AM by JeffeeBoy

    using CFCs statically without cfinvoke

    JeffeeBoy
      We have a set of CFCs that we use as an application API.
      Currently, the way I use them is by instantiating them in the application scope and then creating aliases (for shortened syntax) like this:
      <cfobject name="Application.Company" component="components.company">
      <cfset $Company = Application.Company>

      and then in the application, I call methods like this:
      <cfset qCompany = $Company.GetCompanyDetails(cmpid)>

      -- All of the objects are intented to be used statically and have no instance data, but to use them like this, I've obviously having to create an instance (using CreateObject or cfobject).
      -- The reason I don't use CFInvoke to call methods statically is because I think that it makes the code much more difficult to read.
      -- The one concern I have of using the objects in the way that I am (by creating instances of them and putting those instances into application scope) is that if I forget to "var" any variables in a method, then I have just created "instance data" on the object, and things could get really tough to debug when unexpected behavior starts occurring in the application.

      -- I 'm trying to find a solution to reference my CFCs, and then access them later statically without creating an instance at all. Has anyone ever come up with a solution for this?

      -- As a "last resort", I could always create the objects in Request scope, but there's obviously some performance overhead there.

      Any thoughts on this?