Pages

Wednesday, November 17, 2010

Design Patterns - Singleton

The Singleton is a useful Design Pattern for allowing only one instance of your class.

The Singleton's purpose is to control object creation, limiting the number to one but allowing the flexibility to create more objects if the situation changes. Since there is only one Singleton instance, any instance fields of a Singleton will occur only once per class, just like static fields.

Usage: Singletons often control access to resources such as database connections or sockets.

No comments:

Post a Comment