File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
patterns/builder/conceptual Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ # Builder Pattern
2+ Builder is a creational design pattern that lets you construct complex objects step by step. The
3+ pattern allows you to produce different types and representations of an object using the same
4+ construction code.
5+
6+ ## Diagram:
7+
8+ ![ image] ( https://user-images.githubusercontent.com/8049534/182850365-52969fc7-d743-430b-acc7-da400eae26aa.png )
9+
10+ ## Client code:
11+
12+ ``` dart
13+ void main() {
14+ final director = Director();
15+
16+ final product1 = director.construct(ConcreteBuilder1());
17+ print(product1);
18+
19+ final product2 = director.construct(ConcreteBuilder2());
20+ print(product2);
21+ }
22+ ```
23+
24+ ### Output:
25+
26+ ```
27+ ConcreteBuilder1
28+ 001: one
29+ 002: two
30+ 003: three
31+
32+ ConcreteBuilder2
33+ 1️⃣: first
34+ 2️⃣: second
35+ 3️⃣: third
36+ ```
You can’t perform that action at this time.
0 commit comments