This is his definition:
Use sharing to support large numbers of fine-grained objects.
But I canβt understand what this means.
Can you develop a tiny demo?
The Flyweight template is useful if you need a large number of instances of a certain type. You isolate data that is the same for all of these instances (internal state) in a common object. You save only data that changes in each instance in the instances themselves (external state). The advantage is that memory consumption is clearly less.
This is a common model in the gaming industry, where a common example is Soldiers on the battlefield. All soldiers have the same graphic representation and the same weapon, but their position and health are different. The external state will then be only their state of health and the x / y / z coordinates on the battlefield, while everything else will be in flies.
PHP implementations for this template are easy to find on the Internet. For example,