Strategy Pattern
A pattern where interchangeable classes each hold one way of doing a task.
What is Strategy Pattern?
The Strategy pattern puts each way of doing something in its own class and lets you swap them. A map app can switch between driving, walking and cycling route strategies.
public interface IRouteStrategy { Route Plan(Place from, Place to); }
var planner = new RoutePlanner(new WalkingRoute());
planner.Strategy = new CyclingRoute(); // swap at run time
Level: Freelancer · More OOP terms at this level
Updated