Rules of thumb
- Abstract Factory
Creates an instance of several families of classes - Builder
Separates object construction from its representation - Factory Method
Creates an instance of several derived classes - Object Pool
Avoid expensive acquisition and release of resources by recycling objects that are no longer in use - Prototype
A fully initialized instance to be copied or cloned - Singleton
A class of which only a single instance can existAdapter example Bridge Design Pattern example Fly Weight Pattern example Fascade example
Solid Principles
Found this page interesting on SOLID: open
Factory Vs DI
- https://www.reddit.com/r/javahelp/comments/15mcudc/is_dependency_injection_and_factory_pattern_the/
- Clean Code: Page 188 Fundametal OO concepts - https://github.com/herrera-ignacio/oopnotes?tab=readme-ov-file#fundamentals---composition
Why not worry inheritance in the beginning !
As inheritance is central in the object-oriented method, so is a good inheritance structure — more accurately, a good modular structure, including both inheritance and client relations — essential to the quality of a design. But inheritance is only relevant as a relation among well-understood abstractions. When you are still looking for the abstractions, it is too early to devise the inheritance hierarchy.