O'Reilly logo

Swift 2 Design Patterns by Julien Lange

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The builder pattern

Unlike the abstract factory pattern, which will produce parts of products of the same family, the builder pattern will help us build the finalized product that consists of several parts.

Roles

The main purpose of the builder pattern is to abstract the building of complex objects from its actual construction. Having the same construction process can create different representations of the product.

This pattern can be used when:

  • A client needs to construct complex objects without having to know its implementation
  • A client needs to construct complex objects that need to have several implementations or representations

Design

The following figure shows the generic UML class diagram of the builder pattern:

Participants

This pattern is quite ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required