Skip to main content
nak33
Known Participant
March 29, 2019
Question

Static Methods

  • March 29, 2019
  • 1 reply
  • 867 views

Guys,

We have may CFC in our system and we primarily use them as a means to organize the application, as we have no instance date, but to use them we have to create instances  using cfinvoke.  It is similar to this post made a over 10 years back:

using CFCs statically without cfinvoke

That said from what I can tell CF doesn't have static methods: i.e. a means to create a method in an object and just call that object without instantiating the entire objects (which I'd like to avoid doing).

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
March 30, 2019

nak33  wrote

That said from what I can tell CF doesn't have static methods: i.e. a means to create a method in an object and just call that object without instantiating the entire objects (which I'd like to avoid doing).

That is correct.

nak33
nak33Author
Known Participant
April 4, 2019

There's got to be some solution or alternative as Adobe encourages that backend code be managed in CFC's yet they provide no efficient means to call those CFCs...this makes no sense.  That and the fact that ColdFusion is build on Java, why not leverage static methods.  I really need something to help with the efficiency of our calls.

Community Expert
April 5, 2019

Don't take this the wrong way, but why does there have to be some solution? I mean, this is kind of a perception problem. You don't like the way the language is implemented, compared to Java. I agree that CF's implementation of OOP is not up to speed with Java's, that's for sure. But it's not necessarily a real problem - that is, it may have no actual effect on the performance of your programs.

There's no reason why you couldn't, for example, load a bunch of CFC instances into a persistent scope and call their methods as if they were static. I suspect you'd see equally good performance doing this, and it would take little effort to implement it on your part.

Have you actually measured the efficiency of your calls? What are the exact performance problems you've seen via external measurement?

Dave Watts, Eidolon LLC

Dave Watts, Eidolon LLC