Intent
Separate the construction of a complex object from its representation so that the same construction process can create different representations.
Separate the construction of a complex object from its representation so that the same construction process can create different representations.
Why is this used?
Encapsulates the way a complex object is constructed. This also allows objects to be constructed in a multi-step and varying process (as opposed to one-step factories). Furthermore, this hides the internal representation of the product from the client, while the product implementation can be swapped in and out because the client only sees the abstract interface.
Encapsulates the way a complex object is constructed. This also allows objects to be constructed in a multi-step and varying process (as opposed to one-step factories). Furthermore, this hides the internal representation of the product from the client, while the product implementation can be swapped in and out because the client only sees the abstract interface.
UML diagram representation
https://www.tutorialspoint.com/design_pattern/images/builder_pattern_uml_diagram.jpg
https://sourcemaking.com/design_patterns/builder
https://www.tutorialspoint.com/design_pattern/images/builder_pattern_uml_diagram.jpg
https://sourcemaking.com/design_patterns/builder
Source code example
https://sourcemaking.com/design_patterns/builder/java/2
More to follow...
No comments:
Post a Comment