Singleton
E679867
Singleton is a creational design pattern in software engineering that ensures a class has only one instance while providing a global point of access to it.
Statements (50)
| Predicate | Object |
|---|---|
| instanceOf |
creational design pattern
ⓘ
software design pattern ⓘ |
| advantage |
centralized management of global state
ⓘ
controlled access to a single instance ⓘ reduced memory usage for shared services ⓘ |
| appearsIn | Gang of Four design patterns catalog NERFINISHED ⓘ |
| canBeImplementedIn |
C#
ⓘ
C++ NERFINISHED ⓘ Java NERFINISHED ⓘ JavaScript NERFINISHED ⓘ Python NERFINISHED ⓘ many object-oriented languages ⓘ |
| canBeMadeThreadSafeBy |
double-checked locking
ⓘ
initialization-on-demand holder idiom ⓘ synchronizing the accessor method ⓘ using language-level static initialization ⓘ |
| category | object creational pattern ⓘ |
| commonUseCase |
caching manager
ⓘ
configuration manager ⓘ connection pool manager ⓘ logging service ⓘ window or application controller ⓘ |
| criticizedFor |
encouraging global state
ⓘ
hindering testability ⓘ tight coupling ⓘ |
| describedIn | Design Patterns: Elements of Reusable Object-Oriented Software NERFINISHED ⓘ |
| disadvantage |
difficulty in unit testing
ⓘ
hidden dependencies ⓘ potential concurrency issues ⓘ potential for global state misuse ⓘ |
| ensures | a class has only one instance ⓘ |
| field | software engineering ⓘ |
| hasKeyFeature |
lazy or eager initialization of the instance
ⓘ
restricted constructor access ⓘ single globally accessible instance ⓘ static access method ⓘ |
| provides | a global point of access to that instance ⓘ |
| relatedTo |
Abstract Factory pattern
NERFINISHED
ⓘ
Dependency Injection NERFINISHED ⓘ Factory Method pattern NERFINISHED ⓘ Service Locator pattern NERFINISHED ⓘ |
| supports |
eager initialization
ⓘ
lazy initialization ⓘ thread-safe initialization mechanisms ⓘ |
| typicalImplementationDetail |
private constructor
ⓘ
public static accessor method ⓘ static field holding the instance ⓘ |
| usedFor |
controlling object creation
ⓘ
coordinating access to a single service ⓘ managing shared resources ⓘ |
Referenced by (1)
Full triples — surface form annotated when it differs from this entity's canonical label.