Selecting patterns
Examine the following figure comparing a builder and an abstract factory:
Comparison between the builder and abstract factory patterns
Despite the differences in approach, there are striking similarities between the builder and abstract factory patterns, and they both perform similar functions. We could quite easily use abstract factories for this task. Factories are more flexible when it comes to adding or modifying products, and are structurally a little simpler, but there is one important difference between the two patterns that really determines our choice.
Both factories and builders manufacture objects, but the major difference is that factories return their products as each of them are requested. This would be like having a sandwich delivered one ingredient at a time. The builder, on the other hand, only constructs its output once all the products have been selected, and this is far more like the behavior of making and delivering a sandwich. This is the reason why...