Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bdf765d

Browse files
committed
Detailing builder pattern
1 parent 2454cd5 commit bdf765d

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

‎README.md‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,29 @@ Source files are in the package `com.abstractFactory`.
104104

105105
}
106106
}
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+
import com.builder.Computer;
120+
121+
public class TestBuilderPattenr{
122+
public static void main(String[] args){
123+
124+
Computer comp = new Computer.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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /