 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| |
Applicability
|
|
|
|
|
There must be
exactly one instance of a class and it must be accessible
|
|
to multiple
clients
|
|
|
|
|
The sole
instance should be extensible by subclassing, and clients
|
|
|
should be able
to use subclass without modifying code
|
|
|
| |
Consequences
|
|
|
|
|
Controlled
access to sole instance
|
|
|
|
|
Reduced name
space (over global variable)
|
|
|
|
|
Extendable
implementation
|
|
|
|
|
Permits a
variable number of instances (easy to change if dont want
|
|
|
singleton)
|
|
|
|
|
More flexible
than static member functions allows subclassing and
|
|
|
easy to change
to multiple number of instances
|
|