Imagine that you have to create a new window type, which will have a border; the first idea is borrowed from a window class, and creating a new class called BorderedWindow
. You can do the same thing with scroll bars; call it ScrolledWindow
. Now, if we need to create a window with scroll and border, we have to create a new class called ScrolledAndBorderedWindow
, but imagine that we now need to add a double and triple bordered window, we will have lots of combinations.
To prevent this kind of problem, there is a pattern called decorator; this pattern allows us to create new object types based on a new feature.
Create a new project called Chapter 4 Pizzas
and add the pizza image into Images.xcassets
. Now, heat up the oven and let's prepare some pizzas.