Java Design Pattern Strategy
This document summarizes the Strategy Pattern implemented in Java.
1. Java Strategy Pattern
Strategy Pattern means a Pattern that defines different algorithms (Strategies) as separate Classes and allows the defined Classes to be exchanged and used. Strategy Pattern is used when you want to flexibly change and use various algorithms.
| |
[Code 1] shows a simple Strategy Pattern implemented in Java. The OperationAdd and OperationSub Classes are concrete Classes that implement the Operation Interface, and are Classes that have different algorithms (Strategies). You can see that the Operator Class receives an Operation Class that has an algorithm as a Parameter and uses it.