O'Reilly logo

Android Design Patterns and Best Practice by Kyle Mew

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required