When we reviewed the Factory design patterns, we saw how they were useful for enabling polymorphism. The crucial differentiation between Factory patterns and the Builder pattern is that the Builder pattern solely has the aim of resolving one anti-pattern and does not seek to perform polymorphism. The anti-pattern in question is the Telescoping Constructor.
The Telescoping Constructor problem is essentially where the count of arguments a constructor contains grows to an extent where it becomes impractical to use or even impractical to know which order the arguments go in.
Let's suppose we have a
Pizza class as follows, it essentially contains a constructor and a
show function which details the size and toppings of the pizza. The class ...