CodePark/ questions / Creational patterns
START PRACTICINGPRACTICE
Backend question · Software design & patterns › Creational patterns

Which pattern does this test helper use?

const order = anOrder()
  .withCustomer("c-1")
  .withItem("sku-1", 2)
  .paid()
  .build();
Builder

A builder puts together one object step by step through a fluent API (each method returns the builder, so calls chain). It returns the finished object from build().

An "Abstract Factory" creates families of related objects. It does not configure one object in steps.