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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:34:23+00:00 2026-06-01T19:34:23+00:00

I keep reading over and over again that one should avoid using singletons for

  • 0

I keep reading over and over again that one should avoid using singletons for various reasons. I’m wondering how to correctly handle a situation where a class represents a unique system resource. For example, a AudioOutput class using SDL. Since SDL_OpenAudio can only be open once at a time it makes no sense having more then one object of this type and it seems to me preventing accidentally making more then one object would actually be good.

Just wondering what experienced programmers think about this, am i missing another option ?

  • 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-01T19:34:24+00:00Added an answer on June 1, 2026 at 7:34 pm

    Using design patterns wisely is a tricky questions, and it requires a lot of practice.

    I have seen a lot of people using Singleton just because it “sort of” fits what they need to do. And this often results in disasters, for example in case of multi-threaded environments, or just as it was meant to hide a design flaw and needed a complete system redesign later on.

    I’d say you need to think about a few things when considering Singleton:

    • Do I really need to have only one instance of my object? Am I not trying to hide some design flaw?
    • Does it make sense that my object can be accessed globally?

    But I’d say don’t spend too much time on it: it may not be always the best solution, but this is still an acceptable solution in some cases, and unless you’re in a multi-threaded environment, you’ll probably rarely have issues. It’s mainly a design choice.

    If you want to gain more knowledge about design patterns, I advise this book, which is pretty much the reference on the topic.

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

Sidebar

Related Questions

Over the summer, I've been reading a lot about design. Two notable pieces that
I keep reading everywhere that when you ask for dependencies to be injected in
How do I make it so that the program doesn't keep reading in code
I keep reading how everyone states to return a XmlDocument when you want to
We keep reading about how to use 'readResolve()' to ensure singleness in case of
I used the XMLReader format: XmlReader xmlReader = XmlReader.Create(batch.xml); while (xmlReader.Read()) { //Keep reading
In my reading on dynamic and static typing, I keep coming up against the
I keep a Session variable when the user is logged in. So that when
I'm building an application which uses AutoFac 2 for DI. I've been reading that
I've been searching all over the place for streaming a file into MySQL using

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.