Skip to main content
nak33
Known Participant
Mar 29, 2019 2:55 PM UTC
Question

Static Methods

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 is closed to new replies. Start a new post to keep the conversation going.

4 replies

BKBK
Community Expert
Community Expert
Mar 30, 2019 9:19 PM UTC

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.

Translate
nak33
nak33Author
Known Participant
Apr 4, 2019 9:20 PM UTC

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.

Translate
Community Expert
Apr 5, 2019 4:50 PM UTC

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

Translate
Dave Watts, Eidolon LLC