DEV Community 👩‍💻👨‍💻

Cover image for Strategy Pattern | Design Patterns in Java
coder4life
coder4life

Posted on

Strategy Pattern | Design Patterns in Java

Behavioral design pattern: Watch a Java implementation of the Strategy Pattern which allows us to change the behavior of an algorithm at runtime. In this example there are different payment methods - strategies - for a certain amount. The context processes the payment differently depending on the payment method. A client would at runtime be able to select between the payment methods. The implementation in Main would thereby be more dynamic in a real usecase.

Top comments (0)

Classic DEV Post:

Understanding git through images