CS FundamentalsHardIBM · Deloitte pattern

A PizzaBuilder lets you call .addCheese().addTopping("olives").setCrust("thin").build() to assemble a Pizza step by step, with the same builder able to produce very different pizzas depending on which methods are called and in what order. How does this differ from an Abstract Factory that returns a complete DarkThemeWidgetSet in one call?

  1. A. Builder always produces identical objects regardless of which methods are called
  2. B. Abstract Factory also requires calling methods in a specific build-up sequence before use
  3. C. Builder constructs one complex object incrementally over several calls, often producing different results depending on which optional steps are invoked; Abstract Factory returns a family of already-complete related objects from a single factory call, with no incremental step-by-step construction of one object
  4. D. They are identical patterns under different names

Correct answer: C. Builder constructs one complex object incrementally over several calls, often producing different results depending on which optional steps are invoked; Abstract Factory returns a family of already-complete related objects from a single factory call, with no incremental step-by-step construction of one object

Builder's focus is the step-by-step construction of one complex object (optional steps, varying configurations). Abstract Factory's focus is producing a consistent family of related objects (several different products) in one shot, not incrementally building a single object.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic