🎉 October Learning Month — learn a new software term every day!
An interactive flashcard trainer for software engineering terms.

Strategy

In plain terms

A pattern that lets you swap algorithms at runtime behind a common interface.

Going deeper

The Strategy pattern defines a family of interchangeable behaviors so the caller can pick one without changing its own code. It replaces sprawling conditionals with pluggable objects.

Under the hood

Replaces conditional branching with interchangeable objects; favors composition and open-closed design, at the cost of more classes/objects.

Examples

Sorting comparators, payment-method handlers, compression algorithms, routing options.

Think of it like...

Like choosing a route option in a maps app, fastest, shortest, no tolls: the trip is the same call, but the chosen strategy changes how it's solved.

Feedback & Bug Report