From 29d1f8eabff50380d02cda2d1d1911d959e28155 Mon Sep 17 00:00:00 2001 From: itsmegayu <145862958+itsmegayu@users.noreply.github.com> Date: Fri, 18 Apr 2025 10:15:22 +0530 Subject: [PATCH] Added easy analogy for Singleton pattern using company Leader example --- singleton/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/singleton/README.md b/singleton/README.md index 92505061399e..f6b4d3ea0e9d 100644 --- a/singleton/README.md +++ b/singleton/README.md @@ -37,6 +37,10 @@ Sequence diagram ![Singleton Pattern sequence diagram](./etc/singleton-sequence-diagram.png) +## Easy analogy + + Imagine a singleton like a company's Leader. There can be only one Leader for a company. All employees interact with this single leader instance. No matter how many teams they have in their company, everyone has to refer to that same leader. Similarly, in the Singleton class, there can be only one instance of the class. + ## Programmatic Example of Singleton Pattern in Java Joshua Bloch, Effective Java 2nd Edition p.18