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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:11:42+00:00 2026-05-12T11:11:42+00:00

The ‘singleton-ness’ of a class is an important aspect of how a class should

  • 0

The ‘singleton-ness’ of a class is an important aspect of how a class should be used. However, it usually doesn’t have any explicit status in the exposed API of a class. Yes, conventional method names such as getInstance() are often used, but that’s not exactly what I’m referring to here.

A ‘tag interface’ is an interface which contains no methods or data. An example of a tag interface is Serializable.

Would it not be useful to define a tag interface for singletons? This would:

  • allow them to be easily identified in the code base of a project
  • be more explicit
  • provide a place to document how singletons should be treated. As one example, one could mention that long-lived objects are fruitful sources of memory leaks, and that singletons should never be wired to short-lived objects.

This is a simple idea, but I have never seen it mentioned anywhere.

  • 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-12T11:11:43+00:00Added an answer on May 12, 2026 at 11:11 am

    You’ve stepped into a religious war here, but to me it seems that your idea has merit. So long as there are Singletons, I think it would be good if the compiler and JVM could enforce their atomic singleness.

    The problem is that Singletons have become controversial, because they’re prone to abuse. People opposed to their use point to secret global state, hidden dependencies, and massive overuse.

    None of these, of course, are actually inherent in the notion of Singleton-ness, but that doesn’t change the controversy.

    Your case here isn’t helped by using Serializable, because as Tom points out, that’s controversial in itself. Of course, the fact that Serializable is held to have been a mistake by some writers doesn’t necessarily make it so. Personally, I don’t use it, but not because I think it’s a mistake per se… I just find there are better ways to persist and retrieve state that better match my users’ needs.

    There are, of course, other marker interfaces – Cloneable, EventThreadListener, and SingleThreadModel, if memory serves. You might get further if you used them as a model.

    Incidentally, I think most writers are referring to what you call a “tag interface” as a “marker interface”. Not a big deal, but it might help your search for other thoughts on the topic.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have a reasonable size flat file database of text documents mostly saved in
I have the following tasks in my deploy.rb namespace :unicorn do desc stop unicorn
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.