Skip to content

Commit c6618a4

Browse files
committed
Add README.
1 parent a00f742 commit c6618a4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
```

0 commit comments

Comments
 (0)