Basics
- Abstraction
- Encapsulation
- Polymorphism
- Inheritance
Strategy Pattern
Identify the aspects of your application that vary and separate them from what stays the same
- Take the parts that vary and encapsulate them so that later I can extend the parts that vary without affecting those that don’t. Program to an interface, not an implementation
- Create an interface for the behavior that keeps changing → implement the various behaviors using that interface.
- The actual class that needs those things is just using that interface and is not worried about the actual implementation, it will pull whatever is necessary.
- Programming to an interface just means programming to a supertype → I don’t actually have to use the interface Favor composition over inheritance
- Instead of inheriting their behavior, the classes get their behavior by being composed with the right behavior object
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