File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 2
2
# -*- coding: utf-8 -*-
3
3
4
4
"""
5
+ *What is this pattern about?
6
+ This pattern aims to encapsulate each algorithm and allow them to be
7
+ interchangeable. Separating algorithms allows the client to scale
8
+ with larger and more complex algorithms, since the client and the
9
+ strategies are kept independent of each other.
10
+
11
+ Having the algorithms as an integral part of the client can cause the
12
+ client to be larger and harder to maintain. This is more evident when
13
+ supporting multiple algorithms. The separation of client and algorithm
14
+ allows us to easily replace and vary the algorithm.
15
+
16
+ *What does this example do?
17
+ Below the 'StrategyExample' is an example of the client while the two
18
+ functions; 'execute_replacement1' and 'execute_replacement2' are
19
+ examples of the implementation or strategy. In the example we can see
20
+ that the client can vary it's 'execute' method by changing the
21
+ strategy which is responsible for implementation.
22
+
5
23
http://stackoverflow.com/questions/963965/how-is-this-strategy-pattern
6
24
-written-in-python-the-sample-in-wikipedia
7
25
In most of other languages Strategy pattern is implemented via creating some
You can’t perform that action at this time.
0 commit comments