Tuesday, August 7, 2007

The Singleton pattern

The Singleton pattern is an object-oriented design pattern used to ensure that a class has only one instance and provide a global point of access to that instance. The Singleton pattern can be implemented by doing the following:
  • Implementing a static method that returns an instance of the class
  • Making the constructor private so a class instance can be created only through the static method
  • Using a static variable to store the class instance

No comments: