1. Definition and UML Modeling Diagram
Separate the construction of a complex object from its representation, so that the same construction process can create different representations.

2. Usage Scenarios:
Multiple components or parts can be assembled into one object, but the resulting operation results are the same.
The product class is very complex, or different call sequences in the product class produce different effects.
Initializing an object is particularly complex, such as using multiple constructors, or having many parameters, all with default values.
3. Core Classes
- (1) Abstract product class: computer.
- (2) Builder: the abstract Builder, which standardizes the assembly of the product. Subclasses generally implement the specific assembly process.
- (3) MacbookBuilder: the concrete Builder class, the class that specifically creates objects.
- (4) Directror: unifies the assembly process.
Focusing on assembling a computer, mainly assembling the host, setting up the operating system, and setting up the monitor.
4. Specific Usage
4.1 Abstract Computer Class
Computer.java
4.2 Concrete Product Class MacBook
MacBook.java
4.3 Abstract Builder
Builder.java
4.4 Concrete Builder
MacBookBuilder.java
4.5 Director Class, responsible for the specific construction of Computer
Director.java
4.6 Specific Usage
Test.java
5. Summary
In order to flexibly construct complex objects, the object will have multiple member variables. When called externally, it is not necessary or convenient to create all member variables at once. In this case, using multiple constructors to build objects is difficult to maintain. At this point, the Builder design pattern solves this problem by creating objects in the build() method and passing in the builder. The builder maintains the member variables of the passed-in object.
Author: OneXzgj
Link: https://www.jianshu.com/p/f958ba891467