Strategy Design Pattern — 3 Minute Series
Same context with a different strategy.
Oct 5, 2022
_00 / Concept
When an object’s method behavior changes frequently, then you can try this design pattern. The strategy design pattern lets you inject and switch the behavior of the context at the run time, which we call “strategy.”
_01 / Key Roles
Context and Strategy. Inject “strategy” into “context” and change the method’s behavior.
_02 / Trade-offs
🟢 Abstract the behavior logic and make it easy to maintain and scale.
🔴 User needs to know more to use the strategy since they need to compose the strategy and context by themself.