Design Patterns
- Design Principles: General Guidelines
- Design Patterns: Specific Solutions
- Design Patterns are expressed by a definition, a class diagram and collected into a catalog of patterns
- Some references:
Popular Design Patterns
Important
Other
Practical Design Patterns
- Singleton
- property: global access + must have only one instance (hurts flexibility)
- No true example able to find!! possibly anti-pattern.
- pseudo examples:
- logger object (they are flexible hence not singleton)
- Java Beans (they are restricted to each application context hence not really single instance)
- Builder
- Lombok’s
@Builder annotation
- Decorator (aka Wrapper, Adapter Pattern is also known as Wrapper)
java.util.Collections.unmodifiableList(List)
- convert list to unmodifiable list
- Facade
- Importing libraries
- SLF4J, JPA??
- Iterator
- Interface:
java.util.Iterator
hasNext(): boolean
next(): E
- For-Each loops use Iterator under the hood for Collections
- Observer/Reactor for Project Reactor