design-patterns/behavioral/strategy/concrete_strategies.py
Ruidy 03cb570b65
Strategy (#22)
* add documentation

* add code example
2020-10-09 12:01:22 +02:00

15 lines
440 B
Python

"""
Concrete Strategies implement the algorithm while following the base Strategy interface. The interface makes them
interchangeable in the Context.
"""
from behavioral.strategy.strategy import Strategy
class ConcreteStrategyA(Strategy):
def do_algorithm(self, data: list) -> list:
return sorted(data)
class ConcreteStrategyB(Strategy):
def do_algorithm(self, data: list) -> list:
return reversed(sorted(data))