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_14
Kelt Dockins1
(1)Dolph, Arkansas, USA
$> git checkout flyweightUse sharing to support large numbers of fine-grained objects efficiently.1
The flyweight pattern is used to reduce memory footprint. You will find this pattern helpful whenever you are dealing with a large number of objects that share the same properties or a few objects that share the same large-size data (e.g. images). To illustrate, say you have a Person object that has properties like name, gender, and phone number. Assume the average memory cost for each Person object is 1,000 bytes. When you allocate 100,000 Person objects , you end up with 100 million ...
Read now
Unlock full access