You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: singleton/README.md
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,22 +9,26 @@ tags:
9
9
---
10
10
11
11
## Intent
12
-
Ensure a class only has one instance, and provide a global point of
13
-
access to it.
12
+
13
+
Ensure a class only has one instance, and provide a global point of access to it.
14
14
15
15
16
16
## Explanation
17
+
17
18
Real world example
18
19
19
-
> There can only be one ivory tower where the wizards study their magic. The same enchanted ivory tower is always used by the wizards. Ivory tower here is singleton.
20
+
> There can only be one ivory tower where the wizards study their magic. The same enchanted ivory
21
+
> tower is always used by the wizards. Ivory tower here is singleton.
20
22
21
23
In plain words
22
24
23
25
> Ensures that only one object of a particular class is ever created.
24
26
25
27
Wikipedia says
26
28
27
-
> In software engineering, the singleton pattern is a software design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system.
29
+
> In software engineering, the singleton pattern is a software design pattern that restricts the
30
+
> instantiation of a class to one object. This is useful when exactly one object is needed to
0 commit comments