jeudi 3 août 2023

why do we have unshared objects in fligweight?

why do we have both shared and unshared objects inside fligweight pool? the purpose of flighweight is to share some objects between other objects,so why do we want to have unshared objects?

the gof also said about this that I dont understand it :

UnsharedConcreteFlyweight: not all Flyweight subclasses need to be shared. The Flyweight interface enables sharing; it doesn't enforce it. It's common for UnsharedConcreteFlyweight objects to have ConcreteFlyweight objects as children at some level in the flyweight object structure.

picture from Gof that used unshared objects: enter image description here

Aucun commentaire:

Enregistrer un commentaire