Strategy is a behavioral pattern that lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable. The context class delegates the actual work to a strategy object rather than implementing the algorithm directly. Think of navigation apps: the same 'get directions' request can be fulfilled by a Driving strategy, a Walking strategy, or a Transit strategy — the app switches between them without changing the routing engine.
ℹ️Core idea: define a family of algorithms behind a common Strategy interface. The Context holds a reference to a Strategy and delegates work to it. The algorithm can be swapped at runtime without modifying the Context.
Content is available with subscription.
Get full access to all courses on the platform for one year with a single payment.
▼
Unlike other platforms that charge per course, here you get everything for one price, and after one year of use there will be no automatic charge for the following year.