From the course: Python: Design Patterns (2021)
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Strategy - Python Tutorial
From the course: Python: Design Patterns (2021)
Strategy
- [Narrator] The strategy pattern offers a family of interchangeable algorithms to a client. The problem we often see is that there is a need for dynamically changing the behavior of an object. We offer our strategy class with its default behavior. When there is a need, we provide another variation of the strategy class by dynamically replacing its default method with a new one. Python allows adding methods dynamically by importing the types module.