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 7662213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:44:35+00:00 2026-05-31T13:44:35+00:00

I have this SaveCheckedStateToDB() function: public class oDaA_DBUtils { // TOOD: Perhaps this should

  • 0

I have this SaveCheckedStateToDB() function:

public class oDaA_DBUtils {

    // TOOD: Perhaps this should not be static, and I should force callers to instantiate the class first?
    public static void SaveCheckedStateToDB(int AOptionSelected, String id, boolean AToggledOn)
    {
      //
    }
}

…that I changed to “static” after getting static about calling it from here prior to adding the “static” keyword:

            cbOnDemand.setOnCheckedChangeListener(new OnCheckedChangeListener()
            {
            @Override 
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
                {
                // Contact id is a string?
                oDaA_DBUtils.SaveCheckedStateToDB(oDaA_Consts.ALERT_ON_DEMAND, id, isChecked);
                }
            });

Now it compiles, but is that a “wrong” way of working? Should I remove the “static” appendage/decoration and force callers to instantiate the class prior to calling SaveCheckedStateToDB()?

  • 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-31T13:44:37+00:00Added an answer on May 31, 2026 at 1:44 pm

    There is no reason to un-static it. This method does not need any of the “state” of its class, as it’s obviously a utility class, so it should be static.

    If it’s indeed a utility class, you should enforce it by forbidding instantiation: make the default constructor private:

    private oDaA_DBUtils {
        // no instances allowed!
    }
    

    Also, it’s good practice to follow the Java naming standards: capitalized camelcase for class names, and uncapitalized camelcase for methods. This will help you in the long run to see what you’re doing at first glance when looking at your code.

    public class OdaaDbUtils
    public static void saveCheckedStateToDb(....)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this class class Validator implements iValidation{ protected $_fields, $_errors; public function __construct($fields){
I have this code but it doesn't work! public class Trial { public static
I have this function: public static string Join(this IEnumerable<string> strings, string separator) { return
I have this basic setup: enum{ BASE, PRIMITIVE, ... }; class IUnknown{ public: bool
Have this scenario: public class Base { public string Name; } public Class ClassA
i have this: http://jsfiddle.net/uAQ8B/5/ This list should have all the objects on the left
I have this list: <ul class=pagination> <li class=dl-nav-1 current><a href=#>Spring Training 2001</a><span class=visible><img src=img/indicator.png
I have this code for converting a byte[] to float[] . public float[] ConvertByteToFloat(byte[]
I have this in my object's save class UploadFile < ActiveRecord::Base def save dir
I have this javascript method: <script type=text/javascript> function MyFunction(sender, eventArgs) { if (someCondition) {

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.