Key words: Global access point of the instance, Code Smell

UMLPermalink

Singleton PatternPermalink

Singleton

Pseudo CodePermalink


class Singleton {
  static private Singleton instance;

  private Singleton() {}

  public static Singleton getInstance() {
    if(instance == null) {
      instance = new Singleton();
    }
    return instance;
  }
}

ReferencePermalink