Builder Pattern

-- by Vikram

Possibly a quite straight forward one as the name suggests it all, but what problem does it solve?

Let's say that you are building a custom automobile, and you want to evaluate 20 different garages in the city that do it. You will find that more or less they follow the same steps and sequence, acquire engine, gearbox, wheels and other components fit everything together and later you can take the delivery of your vehicle.

What if a a garage association have told them that don't respond to customer's requirements based on your own interpretation, we will publish a common catalogue and provide to customer's so that when they come to your shop they will always know what to ask for and you will know exactly what respond back, we will also share the same to all the suppliers, so irrespective of which garage customer visits he is always guaranteed that he gets what he wants (can be sourced from different suppliers also as long as they adhere to the catalogue) and in the end you all can fit the components together and deliver the end product to the customer. 

The need of creating variations of a specific type has been addressed by providing an interface that provides a way to step by step create an end product. 

You may expect an interface like it that exposes apis as follows :-

Vehicle customVehicle = VW().customize();
customVehilce.get(); //Returns final product

So it's encapsulating the creation of a final end product and also abstracts away the need to know about how each internal product is created, say if this interface wasn't there you will have to create each objects on your own and pass on to the customizers. Something in real life would be that you procure the part on your own and they just ask the garage to fit in, problem with that approach could be that garage at time might not know how to handle it.