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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:19:53+00:00 2026-05-14T04:19:53+00:00

Should a Singleton class be allowed to have children? Should we seal it? What

  • 0

Should a Singleton class be allowed to have children? Should we seal it? What are the pro’s and con’s?

For being able to inherit from a Singleton class, we would have to make the constructor protected instead of private. Now, that will be fine in c#, but the protected word in java gives both child-classes and package-classes access to the constructor. Which means not only classes that inherit from our Singleton can access the constructor but other classes in the same package can do it.

I’m a bit confused about all this facts. Maybe I am making a big fuss about nothing to worry about too much? Until now, I never had any necessity of trying to inherit from a Singleton, so maybe this is just an academic question!

Thanks

  • 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-14T04:19:53+00:00Added an answer on May 14, 2026 at 4:19 am

    Yes, Singletons should be sealed. No, they should not be inherited.

    The reason is that the primary (really only) behaviour of a Singleton is to create an instance of itself at some predetermined time. Since this functionality is static, it can’t be overridden, so it would have to be duplicated instead. Once you start duplicating, you have multiple instances of a singleton, which doesn’t really make sense.

    Either that or you end up with race conditions or other conflicts as the “derived” singletons fight for control over the global instance, which not only doesn’t make sense, it’s dangerous.

    There are some hackish workarounds to the Singleton inheritance problem, but that is what they are – hacks. The Singleton pattern is not really suitable for inheritance.

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

Sidebar

Related Questions

I'm writing a factory class that should be able to return singleton instances of
I have some class which uses boost singleton. It calls some function from own
I have a doubt,.... How would you create a Singleton class in Flex... Is
I have a ruby class that is using the Singleton pattern. I would like
As per my thoughts, we should make a class as Singleton when we share
Ok, I should simply tell that I want to make a base Singleton class
The 'singleton-ness' of a class is an important aspect of how a class should
How should I write a copy constructor for my singleton class to prevent the
Say that I have a singleton class (Downloader) responsible for downloading and persisting files.
I have a a singleton class here is the code #import <Foundation/Foundation.h> #import CustomColor.h

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.