😽

シングルトンパターン

2021/05/25に公開

The class is instantiated only once, irrespectively of the number of instantiation requests.

  • private constructor: the class cannot be instantiated directly
  • class-level attribute: refers to one instance
  • class-level method for serving the instantiation requests:
    it returns an instance

Discussion