A daily dose of software engineering wisdom - inspiring, thought provoking, and sometimes just plain dangerous.

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: Wednesday 30th June 2010

<<Previous     Next>>

carriagereturn.org home