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
On this page of the site you can watch the video online Using Flyweight pattern in Java project with a duration of hours minute second in good quality, which was uploaded by the user Improve Your Programming skills 15 September 2020, share the link with friends and acquaintances, this video has already been watched 103 times on youtube and it was liked by 3 viewers. Enjoy your viewing!