October 2017
Intermediate to advanced
210 pages
5h 32m
English
Let's start off by looking at how to create a complex structure without the builder pattern to see the problem the builder pattern is designed to solve.
The following code creates a structure named BurgerOld and does not use the builder pattern:
struct BurgerOld {
var name: String
var patties: Int
var bacon: Bool
var cheese: Bool
var pickles: Bool
var ketchup: Bool
var mustard: Bool
var lettuce: Bool
var tomato: Bool
init(name: String, patties: Int, bacon: Bool, cheese: Bool, pickles: Bool, ketchup: Bool, mustard: Bool, lettuce: Bool, tomato: Bool) { self.name = name self.patties = patties self.bacon = bacon self.cheese = cheese self.pickles = pickles self.ketchup = ketchup self.mustard = mustard self.lettuce ...Read now
Unlock full access