The Principles of Design Patterns help to write code that is flexible, reusable and easier to maintain. These principles are:
- Program to an interface, not an implementation
- Favor object composition over class inheritance
- Encapsulate the concept that varies
Interfaces enable polymorphic behavior. We can have several implementations of the same interface and decide which of them to use at runtime.
Factories hide the complexities of creating objects. Factory classes are coupled to types. Consumer classes depend on interfaces.
https://www.amazon.com/dp/B07SX4Z9KD
https://www.amazon.co.uk/dp/B07SX4Z9KD