December 2016
Beginner to intermediate
238 pages
6h 10m
English
© Kelt Dockins 2017
Kelt Dockins, Design Patterns in PHP and Laravel, 10.1007/978-1-4842-2451-9_6
Kelt Dockins1
(1)Dolph, Arkansas, USA
$> git checkout prototypeSpecify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.1
Use the prototype pattern when you want to fork and modify existing objects. A good use for this pattern is when you want to avoid the construction of a class that takes a lot of time or is complicated to create initially. An example of an object with a costly creation is one that uses a web service to fetch data. Once you have the data, though, you no longer need to fetch data from the web service; you just clone the data. There is another ...
Read now
Unlock full access