Skip to content

Commit b5771e7

Browse files
committed
Added Bilder Pattern initial with image
1 parent 10128b0 commit b5771e7

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed
275 KB
Loading
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
# Builder Design Pattern
1+
# Builder Design Pattern :construction_worker:
2+
3+
Builder pattern aims to “Separate the construction of a complex object from its representation so that the same construction process can create different representations.” It is used to construct a complex object step by step and the final step will return the object. The process of constructing an object should be generic so that it can be used to create different representations of the same object.
4+
5+
Builder Pattern is used mostly when large number of deferent types of objects are to be made but these objects use same object building processes (i.e., objects have same methods but those methods do a bit different stuff)
6+
7+
## Explanation with Example
8+
9+
In this example there is a CIVILEngineer class that creates many different types of houses (objects) based on the object of the house blueprint classes. This example contains:
10+
11+
1. **House class:** This class has methods for creating different parts of the house: setRoof(), setFloor(), setInterior(), setWalls(), etc
12+
2. **house blueprint classes:** Many other classes like **IglooBlueprint class**, **TentHouseBlueprint class**, **BambooHutBlueprint class**, etc creates an object of the **House class** and calls its methods with specific parameters to modify the object creation. Eg: **IglooBlueprint class** has a method `buildWalls()` which calls `house.setWalls('Ice blocks')`.
13+
3. **CIVILEngineer class:** This class takes an object of one of the **house blueprint classes** and returns an object of **House class**
14+
15+
<div>
16+
<img alt="Builder Pattern Example" title="Builder Pattern Example" src="/Creational Design Patterns/Builder/Builder Design Pattern Example.png">
17+
</div>

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ The list of 23 Design Patterns is divided into 3 categories: **Creational Design
3737

3838
*Though each of the Design Pattern Category and the Design Patterns belonging to them are self-contained and could be studied in any order, I would prefer to follow the order maintained by the **next section** at the bottom of each page for better flow of information.*
3939

40+
## Points to remember
41+
42+
- In this repository whenever "object" is mentioned it referees to **class objects** (objects instantiated from a class) and NOT the object literal
43+
- Disadvantages are given prior to Advantages.
44+
4045
<hr>
4146
<div>
4247
<p align="right"><i>Next: <a href="/Creational Design Patterns/README.md"><b>Creational Design Patterns --></b></a></i></p>

0 commit comments

Comments
 (0)