Strategy Design Pattern

lets the algorithm vary independently from clients that use it

When to use it?

  • When you want to define a class that will have one behavior that is similar to other behavior in the list.

  • When you need to use one of the several behaviors dynamically

Identify the aspects of your application that vary and separate them from what stays the same.

----

The Strategy pattern can be implemented with a simple anonymous (lambda) function in most modern programming languages.

Code

References

Last updated