Java Design Patterns: Flyweight Live Coding

preview_player
Показать описание
Java Design Patterns: Flyweight Live Coding.
The Flyweight pattern is a structural design pattern that aims to minimize the use of memory
by sharing as much as possible with similar objects.
It's especially useful when a large number of objects with identical or similar data are to be used.

The pattern involves factoring the state of the object into two parts:

👉 Intrinsic state:
This is the data which is shared across the objects, does not change, and is stored in the flyweight.

👉 Extrinsic state:
This is the data that can vary per object and is not stored in the flyweight but passed
by the client code when it needs an object.

Consider a document editor that can handle different fonts.
Instead of creating an object for every character in every font and size (which would be a massive waste of memory),
we could use the Flyweight pattern
Рекомендации по теме
welcome to shbcf.ru