Putting Learnings into code. From the ducker book: head first design patterns.
- Abstraction
- Encapsulation
- Polymorphism
- Inheritance
- Encapsulate what varies
- Favor composition over inheritance
- Program to interfaces, not implementations
- Strive for loosely coupled designs between objects that interact
Defines a family of algorithms, encapsulates each one and make them interchangeable. Strategy lets algorithm vary independently from clients that use it.
Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
The Decorator Pattern attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to sub-classing for extending functionality.
The Factory Method Pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
Classes should be open for extension, but closed for modification.
Depend upon abstractions. Do not depend upon concrete classes.