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.

Image

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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.