- Definition: Design patterns are typical solutions to commonly occurring problems in software design. They are like pre-made blueprints that you can customize to solve a recurring design problem in your code.
- Resources
- Types
- Creational
5 Patterns including 2 factory Patterns
- Structural
7 Patterns
- Behavioral
11 Patterns
- Creational
Creational patterns "abstracts" various object creation mechanisms, which increase flexibility and reuse of existing code.
How classes/objects are structured/defined, mostly around inheritance & composition. How to assemble classes into larger structures while keeping these structures flexible and efficient.
Talks about specific problems & How >1 objects communicate which each other and solve the problem, which single object can not solve. Example observer, COR etc.
- Chain of Responsibility Pattern
- Observer Pattern
- Interpreter Pattern
- Command Pattern
- Iterator Pattern
- Mediator Pattern
- Memento Pattern
- State Pattern
- Template Method
- Strategy Pattern
- Visitor Pattern
- UMLs' are drawn using Plant UML plugin https://plantuml.com/class-diagram
- Use online Plain UML Editor to see the Class diagam using .puml content.
- SingleTon/Factory/Builder/Command(SF Code)/Strategy/Iterator(java iterator)/COR(In Http filter chain)/Mediator(java Thread pool) etc
- Null Object Pattern
- Enum + If-Else vs Polymorphism
- MVC
TODO
- Law of Demeter
- Robustness Principle
- Speculative Generality/YAGNI/Just in Time Design
Don't generalize or create interfaces if you don't need it know . But I am yet to find, any logical reasoning or disadvantages of having these interfaces beforehand
TODO
- Primitive Obsession
- Switch Statements/If-Else Branching