About 51 results
Open links in new tab
  1. .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 …

  2. How do you implement the Singleton design pattern?

    One example is if the constructor of the singleton allocates memory from the heap and you wish that allocation to be predictable, for instance in an embedded system or other tightly controlled …

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

  4. .net - How to implement a singleton in C#? - Stack Overflow

    Oct 29, 2008 · The singleton design pattern (which is very rarely needed) describes a class that is instantiated, but only once, automatically, when first used. It combines lazy initialization with a check …

  5. c++ - Singleton: How should it be used - Stack Overflow

    Sep 18, 2008 · So a singleton should be used if and only if, we need both the traits it offers: If we need global access (which is rare, because globals are generally discouraged) and we need to prevent …

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

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

  7. Difference between singleton and factory method pattern

    Apr 27, 2024 · The Singleton pattern ensures that only one instance of the class exists and typically provides a well-known, i.e., global point for accessing it. The Factory pattern defines an interface for …

  8. What are drawbacks or disadvantages of the 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

  9. How is Meyers' implementation of a Singleton actually a Singleton

    A singleton type by definition needs to resist having more than once instance of it getting created, which is usually achieved by having a private constructor (and a function that returns the only instance).

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