The Singleton Pattern

The Singleton pattern provides a global means to access a unique object while ensuring the extensibility of that object. Figure 6-8 shows the class diagram.


Figure 6-8. Singleton pattern class diagram

This pattern has the following parts:

  • Concrete singleton
  • Singleton interface
  • Abstract Factory Method pattern
    • Abstract product
    • Concrete product
    • Abstract creator
    • Concrete creator
  • Client

The pattern's benefits are as follows:

  • Grants global access to an object
  • Maintains access to its unique instance
  • Reduces the need for multiple global variables
  • Permits subclasses

It also has this drawback:

  • Requires configuration

Get AdvancED ActionScript 3.0: Design Patterns now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.