Chapter 5
The Prototype Pattern
In this chapter I describe the prototype pattern, in which you create new objects by copying an existing object, known as the prototype. The prototype itself is created using a template, as described in Chapter 4, but subsequent instances are clones. Table 5-1 puts the prototype pattern in context.
Table 5-1. Putting the Prototype Pattern into Context
Question | Answer |
---|---|
What is it? | The prototype pattern creates new objects by copying an existing object, known as the prototype. |
What are the benefits? | The main benefit is to hide the code that creates objects from the components that use them; this means that components don’t need to know which class or struct is required to create a new object, don’t need to know the ... |
Get Pro Design Patterns in Swift 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.