You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-1Lines changed: 26 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -104,4 +104,29 @@ Source files are in the package `com.abstractFactory`.
104
104
105
105
}
106
106
}
107
-
````
107
+
```
108
+
109
+
110
+
# Pattern Builder
111
+
112
+
Builder pattern is a creational design pattern as Factory Pattern and Abstract Factory Pattern. This pattern was introduced to solve some of the problems with Factory and Abstract Factory patterns when the Object contains a lot of attributes. This pattern deals with a static nested class and then copy all the arguments from the outer class to the Builder class.
113
+
The sample code where we have a Computer class and ComputerBuilder to build it are available in the package `com.builder.Computer`.
114
+
Here's a test program showing how to use Builder class to get object.
115
+
116
+
117
+
```java
118
+
119
+
importcom.builder.Computer;
120
+
121
+
publicclassTestBuilderPattenr{
122
+
publicstaticvoidmain(String[] args){
123
+
124
+
Computer comp =newComputer.ComputerBuilder(
125
+
"500 GB","2 GB").setBluetoothEnabled(true)
126
+
.setGraphicsCardEnabled(true).build(); // -)
127
+
)
128
+
}
129
+
130
+
}
131
+
```
132
+
There are really various implementations of this pattern in JDK.
0 commit comments