The flyweight pattern (structural design pattern) is used when we need to create many similar objects. Using Flyweight pattern, we reduce the creation of multiple objects. It help save memory and improve performance
If we build a game that creates 1000 soldiers. There are two types of soldier: Sniper and Commando. When using Flyweight pattern, we create 2 objects only. No need to create 1000 objects
Implementation steps:
1. Create an abstract class Soldier
2. Create CommandoSoldier class that extends Soldier
3. Create SniperSoldier class that extends Soldier
4. Create SoldierFactory
Nesta página do site você pode assistir ao vídeo on-line Using Flyweight pattern in Java project duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Improve Your Programming skills 15 Setembro 2020, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 103 vezes e gostou 3 espectadores. Boa visualização!