I am considering using the builder pattern
in order to create complex objects
within my application. However I have a concern over whether it is the correct pattern to use.
Take this example; here we see several concrete PizzaBuilders
being created which works nicely. However, in my application I need the ability to pass in some information relating to what is being built. For example, in the case of the PizzaBuilders
I would need the ability to create a custom pizza
where the user can choose certain things such as the sauce
and the toppings
. It is worth noting that the information I would need to pass into the builders would vary.
Please could you advise whether I am looking at using the correct pattern for this problem or whether there may be something else better suited? If it is the correct pattern for the problem then please could you advise on the cleanest way to pass in the information to the builders? Would it be at the point of instantiation?