LLD__Design_Patterns__Decorator_and_Flyweight_Design_Pattern
LLD__Design_Patterns__Decorator_and_Flyweight_Design_Pattern
Design Pattern
y
Flyweight
Pubg
SWE at radical Knality walls Amul
Ione cream vending machine
Description
cone t black current scoop t strawberry
orange
scoop t mango scoop t cherry
Y
Cost
of the ice cream
list of ingredients
Description of ice
cream
17
getlost11 getDescription
satin
yigttyiiiimnfqt.mg'T
ITI
giggtimate
histstopping
getlostex
U
Dessel
I get
I
V
1
MIngredient
getlost17
t
tf
lone mÉ come
on
Syrup scoop
Them
Icecream
histangsidients ing
addingridient CK
i
getcost 121
I
DescDS
get
Decorator Design Pattern
xp icecream cone
Whenever we are adding something new
R Ice Cream77
getlost 1
getDescription
have
There are 2 Kinds of ingredients that
we
Steph
tour is a base ingredient
W U
Toppings are
add on
h Addons
Base 7
me
at H ETHIER
IMI
orange
For each of these define a clan and each class implements
Step3
the ice cream interface
LeIuecreant
f get lost 17
iI
Chou
t hd
costblack
currant
Black
L
gottes ell t strawberryscoop t await
5005 500
Hft
kzaxj.gg
woot
Ice Creams
Wydonttone
i
drowsyup
Tovecream in
getloster ie
gethostlk Chaoyang
return10 I return15
I this.ie i i
I getDerek ie getlost 15
getDerek getlost1
return Chocosyrup
return or i getdue1 ie getbeset
I
new dhow Scoop
Iman ie
Vanilla scoop
new
Come
new Chocolate
new Chocosyrup
A
Icecream
new OrangeCon
I
ingetcostl finalcast
beset 9 finddesup
ie get
Decorator Design Pattern
we have an entity to which we want to change behaviours
If may
consider using decorator design pattern
add to it's behaviour at runtime
HII
HTML element
Eggman
Fyi
I
bur cache Decorate
envity
Enablesprings
web Application
is both base and add on it will have 2 constructors
If a class
empty constructor
Orangelone 1
Ice cream ie
OrangeCowell
E
I
Icreenean it
orangeCone
this is is
f I
getlost
return to
I Hiiiii
www.t
Flyweight Design Pattern
Chandan Alok
i
ga Fa 1
ygy
2guns player
300bullets player at a time
5 56 m m 7 62m 7
9mn
double 813
thus SAME
cower SAME
enumlint YB
weight SAME
double 813
maxDamage SAME
int YB
ni t t z I X
direction y
double 2413 X
speed
double 2B SAME
manRange
int YB
curloor X
100000 bullets
targetCoor X
I
as 1Pub game
MB
by71 IKB image SAME
2 I IKB
A 108 B
I I
O H GB
I tooMB
Even though you have too ooo bullets not all the
Cajon bullets are completely
distinct from each other
Intrinsic
Extrinsic valueof which remains
whichmight Sanne arose all objects
Values of
changewith time