Origin: | GoF 95 | |||||||||||||||
Reason: | Many instances of a class contain unnecessarily duplicated information. | |||||||||||||||
Synopsis: | Define a single object, the Flyweight, for all the duplicated copies. This instance is shared by the Client. | |||||||||||||||
Example: | A wordprocessor represents glyphs by character code, font, size, color, etc. A paragraph should share equal gliphs, not duplicate them. | |||||||||||||||
Solution: |
|
|||||||||||||||
See also: |
Composite
(used in conjunction with flyweight objects) FactoryMethod (to build flyweight objects) Immutable (implemented by flyweight objects) |