Home | Demos | Design Patterns | Strategy Pattern

Factory | Singleton | Strategy | Iterator | Observer | Proxy | Mediator | Visitor

 

Strategy Pattern

See Code and log output
### **Strategy Pattern**

**Description:**
The Strategy Pattern defines a family of algorithms, encapsulates each one, and
makes them interchangeable within that family. It lets the algorithm vary
independently from clients that use it, promoting flexibility and reusability.

**How and When to Use It:**
- **When to Use:** Use the Strategy Pattern when you have multiple algorithms
for a task and want to switch between them without affecting the clients that
use them.

- **Example:** In an e-commerce application, different shipping strategies
(e.g., standard, express, international) can be selected at runtime based on
user choice or destination.