|
This material was presented at the January 2002 Melbourne ADUG
meeting.
It covers the need for Singletons, customisation facilities provided
by Delphi's object construction and destruction mechanisms, and
a demonstration of the EPC's Singleton classes. While not strictly
following GOF's implementation, our code is true to the intent of
the Singleton Pattern: "To ensure a class has only one instance,
and a global point of access"
Here are some features:
- Suitable as a base class for new or existing classes.
- Implementations based on TObject, TForm and TInterfacedObject.
- Create and destroy like any other object. This greatly simplifies
refactoring and reduces exposure of your design. Reference counting
ensures uniqueness.
- Supports creation of member data in subclasses with minimal
additional coding.
- Thread-safe.
|