Tags: singleton pattern
Singleton Pattern
The Singleton pattern is used when you only need one of a particular object. For example a printer manager object, a database connection pool, etc.
This is achieved by giving the class a private class level method of type itself, making the constructor private, and giving it a class level getInstance() method which returns the only copy of itself.
Singleton's are considered harmful by many these days because they are object-oriented global variables. And we _know_ those are bad.
Last published: Thursday 2nd February 2012
<<Previous Next>>