0 votes
in Design Patterns by
What is Builder pattern?

1 Answer

0 votes
by

Ans 

Builder pattern builds a complex object using simple objects and using a step by step approach. This builder is independent of other objects.

image

The Director class is optional and is used to make sure that the building steps are executed in the right order with the right data by the right builder. It's about validation and delegation.

Builder/Director pattern's steps invocations could be semantically presented by method chaining or so called Fluent Interface syntax.

Pizza pizza = new Pizza.Builder()
                       .cheese(true)
                       .pepperoni(true)
                       .bacon(true)
                       .build();

link

Related questions

0 votes
asked Jul 24, 2023 in Design Patterns by SakshiSharma
0 votes
asked Jul 24, 2023 in Design Patterns by SakshiSharma
...