The flyweight pattern

It is always recommended that you design code with a memory-efficient approach to ensure that the memory footprint of the code is lean, and hence, less likely to clog the system. In the case of the Salesforce platform, it is extremely important as Salesforce imposes various limits, such as governor limits, feature limits, and so on. So, it is advisable to keep track of resource consumption.

The flyweight pattern was initially coined and used by Paul Calder and Mark Linton in relation to the What-You-See-Is-What-You-Get (WYSIWYG) visual editor development. As Graphical User Interface (GUI) applications are memory intensive, the flyweight pattern was used to handle memory efficiently.

The flyweight pattern helps reduce the memory ...

Get Apex Design Patterns 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.