The prototype pattern
The prototype design pattern performs similar tasks to other creational patterns, such as builders and factories, but it takes a very different approach. Rather than rely heavily on a number of hard-coded sub-classes, the prototype, as its name suggests, makes copies from an original, vastly reducing the number of sub-classes required and any lengthy creation processes.
Setting up a prototype
The prototype is at its most useful when the creation of an instance is expensive in some way. This could be the loading of a large file, a detailed cross-examination of a database, or some other computationally expensive operation. Furthermore, it allows us to decouple cloned objects from their originals, allowing us to make modifications ...
Get Android Design Patterns and Best Practice 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.