System Design - 2
📘 Strategy Design Pattern Definition The Strategy Design Pattern is a behavioral design pattern that allows you to define a family of algorithms, encapsulate them in separate classes, and make them interchangeable at runtime . In simple terms: 👉 Instead of writing many if-else conditions , we separate algorithms into different classes and choose them dynamically . 🧠Problem Without Strategy Pattern Imagine a payment system . You support: Credit Card PayPal UPI ❌ Bad Design (Using if-else) class PaymentProcessor: def process_payment(self, payment_type, amount): if payment_type == "credit": print(f"Processing credit card payment of {amount}") elif payment_type == "paypal": print(f"Processing PayPal payment of {amount}") elif payment_type == "upi": print(f"Processing UPI payment of {amount}") Problems ❌ Violates Open Closed Principle ❌ Hard to extend ❌ Too m...