From the course: Design Patterns: Creational

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

How the pattern works

How the pattern works

From the course: Design Patterns: Creational

Start my 1-month free trial

How the pattern works

- [Instructor] Let's take a look at the generic Builder Pattern structure from the Gang of Four catalog and then we'll see how this applies to our example of building cars. We have a Director class. This is the class that's responsible for building the product using the Builder class. The Director will use the Builder interface to assemble the products. And depending on which Concrete Builder it's using that build process will result in different concrete products. Here, the Builder interface has just one method: buildPart. But it's likely that builders in the real world will have multiple methods for building complex objects. Once the Director has called the methods to build the product, the Director needs to get a reference to the finished product. This is where the build method comes in. The build method takes all the parts that have been added to the object via the Builder interface, assembles the final product,…

Contents