Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 712 Bytes

Strategy Pattern.md

File metadata and controls

23 lines (18 loc) · 712 Bytes
title date lastmod
Strategy Pattern
2022-11-08
2023-02-12

Strategy Pattern

Problems we want to solve

  1. A set of interchangeable algorithms or objects that can be decided at run-time
  2. Extensible set of strategies: Open-Closed Principle

Context refers or uses the Strategy interface for performing the algorithm. A and B classes implement the Strategy interface which gives the concrete algorithms.

Pros

  1. Encapsulation
  2. Hides implementation
  3. Allows behaviour change at runtime

Cons

  1. Complexity if overused