RUVIDEO
Поделитесь видео 🙏

Flyweight Design Pattern in Java Explained | Structural Design Pattern смотреть онлайн

Flyweight Design Pattern is Structural Design pattern. Flyweight Design pattern concept is explained with example coding in Java.
A flyweight is an object that minimizes memory usage by sharing as much data as possible with other similar objects.
Java String pool is implemented using flyweight design pattern and that is why optimized for memory usage.

Flyweight Design pattern is a way to use objects in large numbers when a simple repeated representation would use an unacceptable amount of memory. Often some parts of the object state can be shared, and it is common practice to hold them in external data structures and pass them to the objects temporarily when they are used.

Classic example usage of the flyweight pattern in java is the data structures for graphical representation of characters in a word processor.



It might be desirable to have, for each character in a document, a glyph object containing its font outline, font metrics, and other formatting data, but this would amount to hundreds or thousands of bytes for each character.



Instead, for every character there might be a reference to a flyweight glyph object shared by every instance of the same character in the document; only the position of each character (in the document and/or the page) would need to be stored internally.

Another example is the string interning. The Flyweight design pattern is one of the twenty-three well-known GoF design patterns that describe how to solve recurring design problems to design flexible and reusable object-oriented software, that is, objects that are easier to implement, change, test, and reuse.

What problems can the Flyweight design pattern solve?
• Large numbers of objects should be supported efficiently.
• Creating large numbers of objects should be avoided.

When representing large text documents, for example, creating an object for each character in the document would result in a huge amount of objects that couldn't be processed efficiently.
What solution does the Flyweight design pattern describe?

Define Flyweight objects that
• store intrinsic (invariant) state that can be shared and
• provide an interface through which extrinsic (variant) state can be passed in.

This enables clients to (1) reuse (share) Flyweight objects instead of creating a new object each time and (2) pass in the extrinsic state when they invoke a Flyweight operation. This greatly reduces the number of physically created objects.



The intrinsic state is invariant (context-independent) and therefore can be shared (for example, the code of character 'A' in a given character set).The extrinsic state is a variant (context-dependent) and therefore can not be shared and must be passed in (for example, the position of character 'A' in a text document).


This video covers above Example explaining Flyweight design pattern in Java



—————————— Like, Share, Support, Subscribe ?? —————————

✔ FUNDOTECH - https://www.youtube.com/channel/UC20UQGc_nSoen6lCRMpLQYA
✔ FACEBOOK - https://www.facebook.com/JagrukIndian
✔ TWITTER - https://twitter.com/kunal_saxena
✔ INSTAGRAM - https://www.instagram.com/thejagrukindian/
✔ LINKEDIN - https://www.linkedin.com/in/kunalsaxena/
✔ TECHIE KUNAL BLOG - https://techiekunal.blogspot.com

—————————— Recommended Playlist ——————————

AWS
https://www.youtube.com/playlist?list=PL6xaYiRPflAvO7Y1wfQRQnuY2_1gRX9dU

Java
https://www.youtube.com/playlist?list=PL6xaYiRPflAsw3knfUY4iajm5bTlDUixs

How Tos
https://www.youtube.com/playlist?list=PL6xaYiRPflAvHf4KE8g-41TT0g2hxy1tp

Design Pattern
https://www.youtube.com/playlist?list=PL6xaYiRPflAuUS5tXZdS-b2eazy5JkV48

Resume Building Series
https://www.youtube.com/playlist?list=PL6xaYiRPflAur4xi5lcPzkiemT_KhULiB

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Flyweight Design Pattern in Java Explained | Structural Design Pattern» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.