Creational

Builder

Description

Separates the construction of a complex object from its representation so that the same construction process can create different representations.

Where to use

  • Objects with many optional parameters.
  • \n
  • Complex assembly steps.

Real World Example

A 'HouseBuilder'. You can call .setWalls(4), .setRoof('Shingle'), .addGarage().build(). You can use the same builder to make a different house.

Code Example

class Builder:\n    def __init__(self):\n        pass\n\n    def execute(self):\n        print('Executing Builder')