Creational Patterns
1. Singleton
classDiagram
class Singleton {
+static SingletonUPtr& GetInstance();
-Singleton(const Singleton&) = delete;
-Singleton& operator&(const Singleton&) = delete;
}
2. Builder
graph BT
h1[Product]
h21[Part1] --> h1
h22[Part2] --> h1
h23[Part3] --> h1
h1 --> h3(Builder)
2.1. Case1: Meal Package
graph BT
Meal --> MealPackage
Item(Items) --> Meal
Hambuger --> Item
Soda --> Item
3. Factory
flowchart
1[Single Product]
3.1. Case1: Shape Factory
flowchart RL
2.1[Circle] --> 1[Shape Factory]
2.2[Square] --> 1[Shape Factory]
3.2. Case2: Color Factory
flowchart RL
2.1[Red] --> 1[Color Factory]
2.2[Green] --> 1[Color Factory]
4. Abstract Factory
graph LR
1[Multiple Product Families]
4.1. Case1: Color Shape Factory
flowchart BT
ColorShape2DFactory --> IColorShapeFactory
ColorShape3DFactory --> IColorShapeFactory
ColorFactory --> ColorShapeFactory
ShapeFactory --> ColorShapeFactory