Using Flyweight pattern in Java project

Pubblicato il: 15 settembre 2020
sul canale di: Improve Your Programming skills
103
3

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


In questa pagina del sito puoi guardare il video online Using Flyweight pattern in Java project della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Improve Your Programming skills 15 settembre 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 103 volte e gli è piaciuto 3 spettatori. Buona visione!