Closed chriskelly closed 1 year ago
Define allocation strategies as separate functions and pass them into the allocation calculation.
Strategy Design Pattern Reference
Example structure:
class Strategy: def execute(self, *args, **kwargs): pass class ConcreteStrategyA(Strategy): def execute(self, a, b): return a + b class ConcreteStrategyB(Strategy): def execute(self, c, d, e): return c * d * e class Context: def __init__(self, strategy): self._strategy = strategy def set_strategy(self, strategy): self._strategy = strategy def execute_strategy(self, *args, **kwargs): return self._strategy.execute(*args, **kwargs)
Define allocation strategies as separate functions and pass them into the allocation calculation.
Strategy Design Pattern Reference
Example structure: