Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6474609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:36:26+00:00 2026-05-25T06:36:26+00:00

In C#, I created static methods to help me perform simple operations. For example:

  • 0

In C#, I created static methods to help me perform simple operations. For example:

public static class StringHelper
{
    public static string Reverse(string input)
    {
        // reverse string
        return reversedInput;
    }
}

Then in a controller, I would call it by simply using:

StringHelper.Reverse(input);

Now I’m using ColdFusion with Model Glue, and I’d like to do the same thing. However, it seems like there’s no concept of static methods in ColdFusion. If I create a CFC like this:

component StringHelper
{
    public string function Reverse(string input)
    {
        // reverse string
        return reversedInput;
    }
}

Can I only call this method by creating an instance of StringHelper in the controller, like this:

component Controller
{
    public void function Reverse()
    {
        var input = event.getValue("input");
        var stringHelper = new StringHelper();
        var reversedString = stringHelper.Reverse(input);
        event.setValue("reversedstring", reversedString);
    }
}

Or is there some place where I can put ‘static’ CFCs that the framework will create an instance of behind the scenes so I can use it as if it was static, kind of like how the helpers folder works?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:36:27+00:00Added an answer on May 25, 2026 at 6:36 am

    Nope, you are correct, there is no concept of static methods in ColdFusion. I think most would solve this problem through the use a singleton utilities in the application scope that are create when the application starts. So in your App.cfc in onApplication start you might have:

    <cfset application.StringHelper = createObject("component", "path.to.StringHelper") />
    

    Then when you needed to call it from anywhere you would use:

    <cfset reversedString = application.StringHelper.reverse(string) />
    

    Yeah, it’s not as clean as static methods. Maybe someday we could have something like them. But right now I think this is as close as you will get.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a public static class utils.cs I want to use it in
I've created a simple Attribute: [AttributeUsage(AttributeTargets.Method)] public class InitAttribute : System.Attribute { public InitAttribute()
I've created a singleton which in the constructor goes like this: public static class
How do I create class (i.e. static ) variables or methods in Python?
Is a string literal in C++ created in static memory and destroyed only when
My application has a utility class with static methods which are responsible for showing
I've created an C# class that contains 2 static method and I successfully created
I was wondering, why do static Create methods exist? For instance, why use this
When I call a static method like: Something.action(); Since a instance isn't created how
Is it possible to create a generic method with a signature like public static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.