January 2020
Intermediate to advanced
532 pages
13h 31m
English
The builder pattern is used to build a complex object by incrementally building simpler parts of it. We can imagine that a factory assembly line would work in a similar fashion. In that case, a product is assembled step-by-step with more and more parts, and at the end of the assembly line, the product is finished and ready to go.
One benefit of this pattern is that the builder code looks like a linear data flow and is easier for some people to read. In Julia, we may want to write something like this:
car = Car() |> add(Engine("4-cylinder 1600cc Engine")) |> add(Wheels("4x 20-inch wide wheels")) |> add(Chassis("Roadster Chassis"))
Essentially, this is the exact functional pipe pattern described in Chapter 9, Miscellaneous ...
Read now
Unlock full access