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: chapter01_strategy/readme.md
+11-3
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
# Chapter 1: Strategy design pattern
2
2
3
-
> **Strategy**: defines a family of algorithms, encapsulates each one and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
3
+
> **Strategy**: defines a family of algorithms, encapsulates each one and makes them interchangeable.
4
+
> Strategy lets the algorithm vary independently of clients that use it.
The more pythonic approach in my mind is to define methods rather than classes; this does not violate the above definition. The class-based approach is needed in Java and has the advantage of explicitly setting out the required method in an abstract base class.
32
+
The more pythonic approach in my mind is to define methods rather than classes;
33
+
this does not violate the above definition. The class-based approach is
34
+
needed in Java and has the advantage of explicitly setting out the required
35
+
method in an abstract base class.
32
36
33
-
An example from the standard lib is the list `sort()` and `sorted()` methods with the use of an optional `key` parameter. They invite the use of a sorting function or sorting "strategy", as do `min()` and `max()`.
37
+
An example from the standard lib is the list `sort()` and `sorted()` methods
38
+
with the use of an optional `key` parameter. They invite the use of a sorting
39
+
function or sorting "strategy", as do `min()` and `max()`, although this might
40
+
be better seen as a template method as the `key` function is just one part of
0 commit comments