© Kelt Dockins 2017

Kelt Dockins, Design Patterns in PHP and Laravel, 10.1007/978-1-4842-2451-9_4

4. Builder

Kelt Dockins

(1)Dolph, Arkansas, USA

$> git checkout builder

Intent

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

Applications

A builder is good for creating complex products. As discussed in the last chapter, a product can be anything. All the creational patterns focus on producing products. Some products are just naturally complex, though. So in that case, you can delegate the building process to a director and builder. More about that in just a second. A real-life example of the builder pattern is the construction of a car. An assembly line ...

Get Design Patterns in PHP and Laravel now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.