Email: info at xpro.com.au
Phone: +61 3 9479 3988 (Don) +61 0425 784 187(Paul)
Fax: +61 3 9479 1675
Street/Postal:
Suite 3B La Trobe R&D Park,
2 Research Ave, Bundoora Vic 3083, Australia

Yet another Singleton?

Delphi Example code (33kB)

Presentation slides
PowerPoint97(70kB) StarOffice52(229kB)

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.

Copyright © 2001-2003, The Excellent Programming Company