Builder allows client to construct complex object by specifying only its type and content. The client is shielded from the details of the construction.
The builder pattern produces only one main product, but there might be more then one class in that product, but there is always one main product.
When builder is used, the complex object should be created one step at a time, other patterns build the objects in a single step. Example
buildAddress();
buildContactDetails();
buildChildren();
getResult();
Benefits:
- Let you vary product's internal representation
- Isolates code construction and representation
- Gives greater control over the construction process
- Building process can be easily tested and verified (from me)
- The algorithm for creating a complex object should be independent of both the parts the make up the product and how these parts are assembled.
- The construction process must allow different representations of the constructed object

No comments:
Post a Comment