About 50 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. 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 …

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

  4. What is an efficient way to implement a singleton pattern in Java?

    Sep 16, 2008 · This is useful when your singleton needs to inherit from a superclass. You cannot use the enum singleton pattern in this case, since enums cannot have a superclass (they can implement …

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

  6. How to create a Singleton in C? - Stack Overflow

    Apr 29, 2009 · What's the best way to create a singleton in C? A concurrent solution would be nice.

  7. Dagger 2 - what is the purpose of a @Singleton annotation class

    Jun 28, 2015 · Singleton as a class annotation should only be put for Components to define the scope of component or to classes that exposes themselves without modules. Singleton as a method …

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

  9. When to use following Transient, scoped and singleton

    Apr 22, 2021 · Singleton: In situation when you need to store number of employees then you can create singleton cause every time you create new employee then it will increment the number so in that …

  10. How to define Singleton in TypeScript - Stack Overflow

    What is the best and most convenient way to implement a Singleton pattern for a class in TypeScript? (Both with and without lazy initialisation).