Ayumilove Strategy Design Pattern

Strategy Design Pattern Overview

  • Defines a family of algorithms, encapsulates each one, and makes them interchangeable.
  • Identify the aspects of your application that vary and separate them from what stays the same.
  • The varying aspect is pulled out so it can be reused (avoid code duplication).
  • No modification on Dog classes required when adding new or modifying existing bark behavior.
  • Dynamically change bark behavior during runtime.

Before

After

Leave a Reply

Your email address will not be published. Required fields are marked *