• Home
  • Docker
  • Kubernetes
  • LLMs
  • Java
  • Ubuntu
  • Maven
  • Big Data
  • Archived
Design Patterns | Strategy
  1. References
  2. Example
    • The Subject
    • The Strategy
    • The Concrete Strategy (1)
    • The Concrete Strategy (2)
    • The Strategy Context
    • A simple class to test the Strategy design pattern

  1. References
    • Definition: (source: http://en.wikipedia.org/wiki/Strategy_pattern)

      The strategy pattern (also known as the policy pattern) enables an algorithm's behavior to be selected at runtime.

      The strategy pattern:
      ► defines a family of algorithms,
      ► encapsulates each algorithm, and
      ► makes the algorithms interchangeable within that family.

      Strategy lets the algorithm vary independently from clients that use it.

    • Class diagram: (source: http://en.wikipedia.org/wiki/Strategy_pattern)

      Strategy Pattern
  2. Example
    • The Subject:


    • The Strategy:


    • The Concrete Strategy (1):


    • The Concrete Strategy (2):


    • The Strategy Context:


    • A simple class to test the Strategy design pattern:


© 2025  mtitek