Strategy প্যাটার্ন একটি পরিবার সংজ্ঞায়িত করে যা পারস্পরিক প্রতিস্থাপনযোগ্য অ্যালগরিদম/আচরণগুলি নিয়ে গঠিত, প্রতিটি একটিকে encapsulates করে এবং সেগুলিকে রানটাইমে swappable করে তোলে। এটি আপনাকে একটি অ্যালগরিদম গতিশীলভাবে নির্বাচন করতে এবং জটিল শর্তাধীন বিবৃতি এড়াতে দেয়, যা নমনীয়, প্রসারণযোগ্য কোড প্রচার করে।
Strategy প্যাটার্ন কী করে
STRATEGY → encapsulate INTERCHANGEABLE algorithms/behaviors behind a common interface:
→ define a family of strategies (each implements the same interface)
→ the context uses a strategy via the interface → can SWAP strategies at runtime
→ choose the behavior dynamically without changing the context
→ "compose" behavior instead of hardcoding it (favor composition over conditionals)
