Java Design Patterns: Flyweight Live Coding

Veröffentlicht am: 08 November 2023
auf dem Kanal: datmt
26
1

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


Auf dieser Seite können Sie das Online-Video Java Design Patterns: Flyweight Live Coding mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer datmt 08 November 2023 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 26 Mal angesehen und es wurde von 1 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!