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: strategy/README.md
+100-3Lines changed: 100 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,106 @@ tags:
12
12
Policy
13
13
14
14
## Intent
15
-
Define a family of algorithms, encapsulate each one, and make them
16
-
interchangeable. Strategy lets the algorithm vary independently from clients
17
-
that use it.
15
+
Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary
16
+
independently from clients that use it.
17
+
18
+
## Explanation
19
+
20
+
Real world example
21
+
22
+
> Slaying dragons is a dangerous profession. With experience it becomes easier. Veteran dragonslayers have developed different fighting strategies against different types of dragons.
23
+
24
+
In plain words
25
+
26
+
> Strategy pattern allows choosing the best suited algorithm at runtime.
27
+
28
+
Wikipedia says
29
+
30
+
> In computer programming, the strategy pattern (also known as the policy pattern) is a behavioral software design pattern that enables selecting an algorithm at runtime.
31
+
32
+
**Programmatic Example**
33
+
34
+
Let's first introduce the dragon slaying strategy interface and its implementations.
0 commit comments