From Design Pattern by GoF
Participants
•
Singleton
defines an
Instance
operation that lets clients access its unique instanceuniqueinstance
.Instance
is a class operation (that is, a class method in Smalltalk and a static member function in C++).may be responsible for creating its own unique instance
uniqueinstance
.Collaborations
• Clients access a
Singleton
instanceuniqueinstance
solely throughSingleton
'sInstance
operation.
In Class Singleton
, uniqueinstance
is the unique instance, and Instance()
is its get method.
What are the purposes of the other members:
SingletonOperation()
, GetSingletonData()
, andsingletonData
?Thanks.
Nothing in particular, or rather say it has nothing to do with Singleton
, you can just remove it or rename it or whatever you like. It's just a normal method and has nothing to do to your class being a Singleton.