Skip to content

Files

Latest commit

05f691b · May 28, 2024

History

History

Strategy

Strategy Pattern

Behavioral Type

Use cases:

this pattern is used when an object change its behavior based on its internals state diffrent of strategy pattern and state pattern its that strategy there is no single state , diffrent behaviors represent by diffrent strategy objects.

hints

a main class have some behavioral that the sub class have these too but not identical with eash other so every behavioral have interface and set of classes of that

Classes

  • Context - main class that get object for action
  • Strategy - the abstract class/interface that concreteStrategy classes implement it
  • ConcreteStrategy - class that take action on request diffrently from another concretestate class

Interfaces

  • Interface Strategy

Visual Diagram

Context

Context

|

State

Strategy

|

ConcreteStrategy-A

ConcreteStrategyA

|

ConcreteStrategy-B

ConcreteStrategyB

|