1 Preface
In object-oriented software design, using public objects not only saves resources but also improves performance. Shared Objects can only provide some internal information, but cannot be used to identify objects. A Design pattern specifically used to design shared objects is called the Flyweight pattern ).
2. Details
2.1 Brief Introduction
Two key components are required to implement the metadata sharing mode. They are usually shared object objects and their pools. A central object maintains this pool and returns an appropriate instance from it.
Use the sharing technology to effectively support a large number of fine-grained objects.
2.2 When to use
(1) applications use many objects;
(2) saving objects in the memory will affect the memory performance;
(3) most special states (external States) of objects can be put outside and lightweight;
(3) After the external State is removed, a small number of shared objects can be used to replace the original group of objects;
(4) applications do not rely on object identifiers because shared objects cannot provide unique identifiers.
3 conclusion
The above is all content and I hope it will help you.