Intent:
- Ensure that a class has one and only one instance, and provide a global point of access to the instance
- Exactly N instance(s) of a class needed:
- must be accessible to clients
- a well-known access point
- When class of sole instance should be extensible
Participants:
- Singleton defines an Instance operation that lets clients access its unique instance.
- Instance is a class operation (e.e. static member funciton in C++).
- May be responsible for creating its own unique instance.
Client accss a Singleton instance solely through Singleton's instance operation
- Controlled access to sole instance.
- Reduced name space.
- Permoits refinement of operations and representation.
- Permits a variable number of instances.
- More flexible than class operations.
- Settings
- Configuration Data
- Read-only Data / Cache
- Print spooler
No comments:
Post a Comment