Implemented the examples from the book "Head First Design Patterns: A Brain-Friendly Guide" in ABAP.
Due to the differences between ABAP and Java(which is used in the book), the examples are not exactly like in the book - e.g. in the book there is a void method that prints a string to the console but in ABAP I implemented it with a method returning the string because it cannot be printed directly in the console like in Java.
The Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
- Identify the aspects of your application that vary and separate them from what stays the same.
- Program to an interface, not an implementation.
- Favor composition over inheritance.