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?
- A. Builder always produces identical objects regardless of which methods are called
- B. Abstract Factory also requires calling methods in a specific build-up sequence before use
- 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
- 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.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- An event bus lets any number of modules call bus.subscribe("orderPlaced", handler) and the bus invokes every registered handler when…
- A parser builds an abstract syntax tree where each node type (NumberNode, AddNode, MulNode) implements its own evaluate() method directly…
- A notification system has a base Notifier.send(message) and wrappers SMSDecorator, SlackDecorator that each wrap a Notifier and add their…
- A spreadsheet's Cell objects can contain other Cells (a range), and client code calls cell.getValue() uniformly whether cell is a single…
- A rendering engine has a Shape hierarchy (Circle, Square) and a separate Renderer hierarchy (VectorRenderer, RasterRenderer), and any…
- A text editor needs to support thousands of on-screen Character objects efficiently. Most of a Character's data (font, size, color) is…