The Abstract Factory pattern
After Kitty finishes her initial design using the factory method, Phoebe checks Kitty’s work on GitHub. Phoebe has managed to finish the tooling that creates the frames and she’s hard at work on some of the other parts that go into making a bicycle.
“Kitty!,” Phoebe says, “This code will allow us to make a bicycle object but that’s a little bit too abstract. A bicycle is made of lots of different parts.” After a long discussion, the two decided to concentrate on manufacturing the bicycle frame and the handlebars for each bicycle type. The other parts, such as the wheels, tires, brakes, and gears, can be outsourced for the initial production of the bicycles.
It occurs to Phoebe that these parts can be made in families. The road bike uses dropped handlebars, while mountain bikes use a flat handlebar design. You shouldn’t interchange these parts. Flat handlebars on a road bike create a new class...