"Flyweight" "Ez a példa egy image osztályt mutat be melytől le lehet kérni a Save es a Help ikont. A terminta ott valósul meg hogy ezeknek az ikonoknak csak egy példanyukat tároljuk el egy pool-ban." Image class>>initialize "Set the class' initial state." "[Image initialize]" Smalltalk at: #ImagePool put: IdentityDictionary new. ^self Image class>>release "Prepare the class to be deleted." "[Image release]" Smalltalk at: #ImagePool put: nil. Smalltalk removeKey: #ImagePool. ^self Image class>>imageCache "Return the Image caching dictionary." ^ImagePool Image class>>createSaveIcon "Create and return the Image for the Save icon." ^MainMenUI createSaveIcon Image class>>helpIcon "Return the Image for the Help icon." | cacheDictionary | cacheDictionary := self imageCache. ^cacheDictionary at: #help ifAbsent: [cacheDictionary at: #help put: self createHelpIcon] Image class>>saveIcon "Return the Image for the Save icon." | cacheDictionary | cacheDictionary := self imageCache. ^cacheDictionary at: #save ifAbsent: [cacheDictionary at: #save put: self createSaveIcon] Object subclass: #ImageFactory instanceVariableNames: 'imagePool ' classVariableNames: 'Singleton ' poolDictionaries: '' ImageFactory class>>initialize "Set the class' initial state." "[ImageFactory initialize]" Singleton := self new. ^self ImageFactory class>>release "Prepare the class to be deleted." "[ImageFactory release]" Singleton := nil. ^self ImageFactory class>>default "Return the class' primary instance." ^Singleton ImageFactory>>initialize "Set the instance's initial state." imagePool := IdentityDictionary new. ^self ImageFactory class>>new "Create and return an instance of the class." ^self basicNew initialize