Vikas     Feb,08 2017

Static Method Implementation in ColdFusion

I found some discussion about static method equivalence in ColdFusion.

In C# we can declare class as static and static class can only have all the static methods and static variables. And we can call static class methods without creating its instance.

In ColdFusion we must need to create an instance of cfc. Then & then we can call it’s method. To avoid creating instance each time, you can create object in Application init() function, and make it at application scope, so you can directly call the methods. But this is still a nasty approach, as we are still creating an object when Application initializes.

Then I remember that ColdFusion is not an Object Oriented Language. We make it look like OOP! It happens mostly when we use ColdBox or Model Glue or any other application framework, where most of the coding is in cfc only. Now a days people are using cfscript tag more as Lots of tags are now available in cfscript. And when we use cfscript tag, we feel like it's an OOP language! But remember ColdFusion is a scripting language as PHP and Classic asp. cfscript tag itself trying to remind us by its name!