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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:35:18+00:00 2026-06-03T08:35:18+00:00

In the quest for more opinions I rewrite the question (I´m learning how to

  • 0

In the quest for more opinions I rewrite the question (I´m learning how to ask and English is not my mother tongue)…

Is it redundant or best practice to keep all the methods and global vars as static? (I mean there´s only one instance already per se)

  • 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-06-03T08:35:19+00:00Added an answer on June 3, 2026 at 8:35 am

    If none of the methods depend on the state (the instance attributes) of the class, then you don’t need a singleton, simply declare them all as static – you’ll have an utility class then (that’s the second approach proposed in the question).

    On the other hand, if the methods do depend on the state of the class, and you must ensure that only one instance of the class exists at any moment in time, then use a singleton (that’s the first approach suggested in the question).

    Notice that the second approach is not really considered a singleton, by definition a singleton is a pattern “used to implement the mathematical concept of a singleton, by restricting the instantiation of a class to one object“, and a class with all-static methods doesn’t need to be instantiated at all.

    EDIT :

    Regarding the invocation of static methods in a singleton class, it’s considered bad style to invoke static methods on an object instance, it doesn’t matter if it is a singleton or not. This has been discussed extensively in previous posts. So for consistency, I believe it’d be better to declare all the methods in a singleton as non-static, even if they don’t depend on instance attributes, and access all of them through the singleton (the first approach in your question).

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

Sidebar

Related Questions

It is a very generic question (not related to any application). Just my quest
A bit of a silly question for more advanced programmers, but In my quest
In the quest to make my data more accessible, I want to store my
In a quest for handling events (like mouse moves and clicks) not by subclassing,
Continuing my quest of learning Java by doing a simple game, i stumbled upon
This is more of a theoretical question than code: What i did till now
On my quest to learn more about automated testing by getting a small C++
I realise this is more of a semantic quest rather than a functionality quest.
In the never-ending quest for UI responsiveness, I would like to gain more insight
Continuing my quest to learn more about Backbone.js I have arrived to a situation

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.