About 297,000 results
Open links in new tab
  1. How do you implement the Singleton design pattern?

    1424 In 2008 I provided a C++98 implementation of the Singleton design pattern that is lazy-evaluated, guaranteed-destruction, not-technically-thread-safe: Can any one provide me a sample of Singleton …

  2. What are the real world applications of the singleton pattern?

    Apr 9, 2009 · Simple. What does a singleton do? It provides global access to an instance of an object, and It guarantees that no more than one instance of that type can ever be created. So you use a …

  3. .net - What is a singleton in C#? - Stack Overflow

    Jan 28, 2010 · A singleton is a class which only allows one instance of itself to be created - and gives simple, easy access to said instance. The singleton premise is a pattern across software …

  4. On design patterns: When should I use the singleton?

    The glorified global variable - becomes a gloried global class. Some say breaking object-oriented design. Give me scenarios, other than the good old logger where it makes sense to use the singleton.

  5. What is the best way of implementing a singleton in Python?

    Jun 10, 2020 · This question is not for the discussion of whether or not the singleton design pattern is desirable, is an anti-pattern, or for any religious wars, but to discuss how this pattern is best …

  6. How do you implement a singleton efficiently and thread-safely?

    Jan 9, 2024 · 0 ACE singleton implementation uses double-checked locking pattern for thread safety, you can refer to it if you like. You can find source code here.

  7. Why is Singleton considered an anti-pattern? - Stack Overflow

    I've heard recently that Singleton is an anti-pattern. I know it has to do with the fact making a class singleton is like making that unique instance a global variable, but it's also doing a lot more than that …

  8. Thread Safe C# Singleton Pattern - Stack Overflow

    Sep 7, 2012 · The pattern you see here is called double-checked locking. Its purpose is to avoid the expensive lock operation which is only going to be needed once (when the singleton is first …

  9. What are drawbacks or disadvantages of singleton pattern?

    The singleton pattern is a fully paid up member of the GoF 's patterns book, but it lately seems rather orphaned by the developer world. I still use quite a lot of singletons, especially for factory classes, …

  10. Dependency Injection & Singleton Design pattern - Stack Overflow

    Apr 18, 2010 · How do we identify when to use dependency injection or singleton pattern. I have read in lot of websites where they say "Use Dependency injection over singleton pattern". But I am not sure …