


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



1
organization.each person in a anicon with a name under it forWe want to draw a small folder
for “not Selected.”one for “is Selected” and oneWe want two types of icons,
Lets code it. 3
created.one of each has beenadditional instances onceclass, but does not createunselected folder drawingeither the selected or theFolderFactory that returnsInstead, we’ll create a
return one or the other.both at the outset and thencase, we just create themSince this is such a simple
5
7
generate a very large number of small class instances to represent data.There are cases in programming where it seems that you need to
fundamentally the same except for a few parameters.you need to instantiate if you can recognize that the instances areSometimes you can greatly reduce the number of different classes that
be greatly reduced.them in as part of a method call, the number of separate instances canIf you can move those variables outside the class instance and pass
classes.The Flyweight design pattern provides an approach for handling such
It refers to the instance’s (^) intrinsic (^) data that makes the instance unique, and the (^) extrinsic (^) data which is passed in as arguments.
individual characters or icons on the screen.The Flyweight is appropriate for small, fine-grained classes like