--- --- Lesson 3 - The Decorator Pattern The Decorator Pattern (also known as the wrapper) is a Structural Design Pattern. Structural patterns explain how to assemble objects and classes into larger structures while keeping these structures flexible and efficient. It allows us to dynamically add properties to objects at runtime. The goal is to combine a single concrete class with one or more Decorators. Definition Decorator is a structural design pattern that lets you attach new behaviours to objects by placing these objects inside special wrapper objects that contain the behaviours. The Decorator Pattern allows behaviour to be added to an individual object , either statically or dynamically without affecting the behaviour of other objects in the same class. - Wikipedia The Decorator Pattern attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality. - Head First Design Patterns Provides
Lesson 2 - The Strategy Pattern The Strategy Pattern is a Behavioural Design Pattern. Behavioural Design Patterns are design patterns that identify common communication patterns among objects and realise these patterns and in doing so increases flexibility, carrying out this communication. Definition The Strategy Pattern defines a family of algorithms, encapsulates each one and makes them interchangeable. Strategy lets the algorithm vary independently from the clients that use it. When to use ? When you want to use different variants of an algorithm within an object and be able to switch from one algorithm to another during runtime. When you have a lot of similar classes that only differ in the way they execute some behaviour. To isolate the business logic of a class from the implementation details of algorithms that may not be as important in the context of that logic. When your class has a massive conditional operator that switches between different variants of the same algo