Design Pattern: Singleton

The singleton design pattern is one of a kind, The singleton is a creational pattern that makes sure you only have one instance of a class, while providing global access to this object.

Requirements:

  • Must use a private constructor preventing new instantiations of this class
  • a static method that acts like a constructor, “getInstance()” that returns the same instance of your singleton class or if no instance exist returns a new one.

UML Diagram example

Leave a comment

Design a site like this with WordPress.com
Get started