About 154,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 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, …

  3. 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.

  4. 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 …

  5. Simplest/cleanest way to implement a singleton in JavaScript

    What is the simplest/cleanest way to implement the singleton pattern in JavaScript?

  6. .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 …

  7. c++ - How to implement multithread safe singleton in C++11 without ...

    Aug 30, 2019 · 5 IMHO, the best way to implement singletons is with a "double-check, single-lock" pattern, which you can implement portably in C++ 11: Double-Checked Locking Is Fixed In C++11 …

  8. Is Meyers' implementation of the Singleton pattern thread safe?

    May 23, 2017 · In C++03, this code wasn't thread safe. There is an article by Meyers called "C++ and the Perils of Double-Checked Locking" which discusses thread safe implementations of the pattern, …

  9. Why use singleton instead of static class? - Stack Overflow

    Even though IMHO the singleton pattern is a rather overused pattern, it does sometimes offer benefits, such as: The ability to use different kinds of objects (that inherit from the same base) as the instance …

  10. 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 …