Pattern SW Design
Singleton: participants and collaborations
Classes comprise a Singleton and Clients interface with Singleton.
Classes comprise a Singleton and Clients interface with Singleton
The Singleton is a particularly simple pattern because it only has one class and two responsibilities. Thus, its participant list looks like this:
Create the unique instance
Provide a reference or pointer to that instance
Most patterns have much larger participant lists.
Singleton is such a simple pattern that it really does not say much about collaborations. Its collaborations list looks like this:
Clients use the
method to get a pointer or reference to the unique instance of the Singleton.
is any object or class outside the pattern; generally one that only knows about the public interface that the pattern and its classes present, rather than about its private implementation.