Monday 3 July 2017

Software Engineering: Builder Pattern

Creational Pattern - Builder Pattern


Intent
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.


UML diagram representation


https://www.tutorialspoint.com/design_pattern/images/builder_pattern_uml_diagram.jpg


Example of Builder
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

Software Engineering: Bad Smells! (Smelly code)

Bad Smells! What are bad smells? This refers to any symptom in the source code of a program that possibly indicates a deeper problem.  ...