|
7 | 7 |
|
8 | 8 | ### Creational |
9 | 9 |
|
10 | | -- Singleton - Eager (static) or Lazy (broken pre-JDK5). Eg: Logger, Configurer |
11 | | -- Factory - Eg: Trade type (Bonds, Bill, Notes) |
12 | | -- Abstract Factory - Factory of factories but related products. Eg: Trade Type (GermanBond, EuroBond, GermanBill, EuroBill) |
| 10 | +- Singleton - Single instance of class. Either Eager (static) or Lazy (broken pre-JDK5). Eg: Logger, Configurer |
| 11 | +- Factory - Create types of instances. Eg: Trade type (Bonds, Bill, Notes) |
| 12 | +- Abstract Factory - Factory of factories of related products. Eg: Trade Type (GermanBond, EuroBond, GermanBill, EuroBill) |
13 | 13 | - Builder - Eg: StringBuilder, PizzaMaker |
14 | 14 | - Prototype - Copying costly-creation objects. Classes should implement clone or similar method. |
15 | | -- Object pool - Eg: Threadpool |
| 15 | +- Object pool - Re-use instances. Eg: Threadpool |
16 | 16 |
|
17 | 17 | ### Behavioral |
18 | 18 |
|
|
27 | 27 | - Interpreter - Format converter. Eg: JVM converts byte to native for JVM. |
28 | 28 | - Memento - Save and restore state of object. |
29 | 29 |
|
30 | | - |
31 | 30 | ### Structural |
32 | 31 |
|
33 | 32 | - Adapter - Adapting to a non-direct-compatible class/module/system. |
34 | | -- Decorator - Eg: FileReader, BufferedReader |
| 33 | +- Decorator - Wrap class with another Eg: FileReader, BufferedReader |
35 | 34 | - Facade - Hiding complexity behind simple interfaces. Eg: Turbo Tax |
36 | | -- Proxy - Eg: Hibernate proxy for lazy fetch |
| 35 | +- Proxy - Eg: Hibernate proxy for lazy fetch. @Spy instances for JUnit/Mockito. |
37 | 36 | - Flyweight - Store common characteristics of multiple objects in single place. Eg: Glyph for all characters in a document. |
38 | | -- Bridge - |
| 37 | +- Bridge - Decouple abstraction from implementation so that both can vary independently. Bridge pattern is often created using Adapter pattern. |
39 | 38 | - Composite - Eg: Folder and files |
40 | 39 |
|
41 | 40 |
|
0 commit comments