From the course: Advanced Python: Build Hands-On Projects with Design Patterns (2023)

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Builder pattern

Builder pattern

- Builder is a creational design pattern. It addresses an Anti-pattern called telescoping constructor. An Anti-pattern is the opposite of the best programming practice and what we want to avoid. The telescoping constructor Anti-pattern occurs when a software developer attempts to build a complex object using an excessive number of constructors. Think of a scenario in which you're trying to build a car. This test requires various car parts to be first constructed individually, and then assembled. The Builder Pattern brings order to this chaotic process to remove unnecessary complexity as much as possible. It partitions the process of building a complex object into four different roles. The first role is a director in charge of actually building a product. The second role provides all the necessary interfaces required in building an object. We call this one an Abstract builder because there'll be a ConcreteBuilder…

Contents