Which design pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable?

  • Singleton Pattern
  • Factory Pattern
  • Strategy Pattern
  • Prototype Pattern
The Strategy design pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. It allows you to define a set of algorithms, encapsulate them in separate classes, and make them interchangeable at runtime, enabling the client to choose the appropriate algorithm without altering its code. This pattern is especially useful when you want to provide multiple ways to accomplish a task, such as sorting, without changing the client code.
Add your answer
Loading...

Leave a comment

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