Chapter 12. The Singleton Pattern

In this chapter, we'll take up the Singleton pattern. This pattern is grouped with the other creational patterns, although it is to some extent a pattern that limits the creation of classes rather than promoting such creation. Specifically, the Singleton assures that there is one and only one instance of a class, and it provides a global point of access to it. There are any number of cases in programming where you need to make sure that there can be one and only one instance of a class. For example, your system can have only one window manager or print spooler, or a single point of access to a database engine. Your PC might have several serial ports, but there can be only one instance of “COM1.”

Creating Singleton ...

Get Visual Basic Design Patterns: VB 6.0 and VB.NET 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.