> Design Patterns > Singleton Design Pattern
Singleton design pattern is used to create one and only one instance of a class.
The intent of singleton design pattern is to have only one instance of a class and it should be accessible to multiple clients through well-defined access point.
There are scenarios where one and only one instance of class is required, for example File System, System Manager etc and it has to be accessed from multiple applications. Introducing of global variable provides access to multiple applications but does not make sure that there will be only one instance.
The class itself can take the responsibility of creation of not more than one instance and can provide the well-defined access point for multiple applications.
Here is the singleton design pattern example.
There should be only one Network Manager required to manage the network. Ensure there is only one instance of Network Manager, and provide a global point of access to it.
|C++||Singleton Pattern in C++||Singleton Pattern C++ Example|
|C#||Singleton Pattern in C#||Singleton Pattern C# Example|
|Java||Singleton Pattern in Java||Singleton Pattern Java Example|
|Python||Singleton Pattern in Python||Singleton Pattern Python Example|
|PHP||Singleton Pattern in PHP||Singleton Pattern PHP Example|
|Ruby||Singleton Pattern in Ruby||Singleton Pattern Ruby Example|
|Swift||Singleton Pattern in Swift||Singleton Pattern Swift Example|
|Objective-C||Singleton Pattern in Objective-C||Singleton Pattern Objective-C Example|