LearningTech

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:
    def __init__(self):
        pass

    def execute(self):
        print('Executing Builder')