Skip to content

Commit 29d1f8e

Browse files
committed
Added easy analogy for Singleton pattern using company Leader example
1 parent d80eca1 commit 29d1f8e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: singleton/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ Sequence diagram
3737

3838
![Singleton Pattern sequence diagram](./etc/singleton-sequence-diagram.png)
3939

40+
## Easy analogy
41+
42+
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.
43+
4044
## Programmatic Example of Singleton Pattern in Java
4145

4246
Joshua Bloch, Effective Java 2nd Edition p.18

0 commit comments

Comments
 (0)