Tuesday, December 19, 2006

Flyweight Design Pattern

I was wondering about Flyweight pattern for so many days. Let me present its definition and some detail.

Flyweight pattern: Flyweight is one of the structural patterns. The Flyweight Design Pattern is useful when there is the need for many, many objects to exist that share some information. Several thousand or even several hundred thousand objects might be needed, and this is usually very memory-consuming to keep track of. Given certain constraints, it is possible to reduce this problem greatly and make the presence of so many objects possible. If all of the objects share some intrinsic, invariant information that is constant among all of them, it can be removed from each object, and referenced. This eliminates the redundancy of having to repeat the same invariant, intrinsic information for each object, so instead of storing the same information n times for n objects, it is only stored once. This object that contains all of the intrinsic information is called a flyweight object.
It is possible for a flyweight to have extrinsic information as well. This information must be stateless and determined by context, having no stored values, but values that can be calculated on the spot.
The different components involved in the Flyweight Pattern are the Flyweight, the ConcreteFlyweight, the FlyweightFactory and the Client.

One classic example of a flyweight pattern is the characters stored in a word processor. Each character represents an object that has a font face, font size, and other formatting data. As you can imagine, a large document with this data structure would bloat the memory footprint of the word processor. Moreover, since much of this data is repeated, there must be a way to reduce the footprint - the Flyweight pattern. Each of the character objects would contain a reference to a separate formatting object which contains the required properties. This greatly reduces the memory footprint by combining all of the like-formatted characters into simpler objects that reference a single formatting object.

In Design Patterns, the Gang of Four (GOF) authors describe the Flyweight pattern like this:

Use sharing to support large numbers of fine-grained objects efficiently.

47 Comments:

Anonymous Anonymous said...

同志聊天室666成人kyo成人動漫台灣情色網88 school38ga片下載鋼管舞sex520貼影片a片網站巨乳影片性交友歐美自拍慧慈偷拍性感女優自拍與偷拍歐美免費a片av女優影片美女圖庫吊帶襪美女dudu sex歐美模特兒寫真影片欣賞av成人影城日本素人大全集人體彩繪模特兒85cc免費成人影片18禁的遊戲性感美腿gogo2sex com正妹交友ggooroom 18自拍照吃漢俱樂部火影忍者a圖裸體辣妹超熟女旅館偷拍聊天室交友凹凸情趣用品av免費影片視訊妹妹照片一覽irszx 視訊交友成人色情影片色情偷窺波霸美女老師檳榔西施自拍照片辣妹好露ss369成人色網avi播放程式下載免費a片線上看卡通18美少女圖完美女人

7:02 AM  
Anonymous Anonymous said...

要像鐵鎚和釘子一樣,永遠向著定點努力。..................................................

3:27 AM  
Anonymous Anonymous said...

你所貫徹的形象,你喜愛它有多少百分比,你就幸福多少百分比..............................

5:22 AM  
Blogger 發言 said...

旁觀自己的悲傷是解脫,主觀自己的悲傷是更加悲傷..............................

5:23 AM  
Anonymous Anonymous said...

好文章給人的感覺就是很好,謝謝您~~........................................

5:33 AM  
Blogger 氣死我 said...

珍惜當下..活在當下..祝大家都平平安安健健康康!........................................

5:33 AM  
Blogger 玉鳳 said...

thank for share, it is very important . ̄︿ ̄

8:06 PM  
Anonymous Anonymous said...

Anyone can hold the helm when the sea is calm...................................................

4:58 PM  
Anonymous Anonymous said...

Make hay while the sun shines.......................................................

10:40 PM  
Anonymous Anonymous said...

視訊電話ggoo 視訊-愛情館 黑色豪門企業綜合娛樂論壇 8591論壇 avonline免費a片 xo7777net 貓咪論壇 視訊做愛 0951影片下載avdvd mobile01論壇 免費視訊ggoo 成人論壇 視訊聊天-成人網 plus論壇 交友網 bbs論壇 s383av730 香港論壇 月光論壇 一本道a片東京熱論壇區 aio視訊交友愛情館 78論壇 69成人視訊 伊利論壇 666成人網 bt論壇 禁地論壇discovery影片下載 無碼下載56com影片下載 壞朋友論壇 56com影片下載內衣模特兒寫真 台灣情色綜合論壇 拓網交友AV影城 34C正妹拓網交友 拓網交友視訊聊天室 拓網交友 黑色豪門企業娛樂綜合論壇 貓貓論壇 我愛78論壇 網際論壇 禁地論壇 上班族視訊情色小站 視訊情色小站 情色a片-情色小站 北台灣視訊sexygirlvideomovie sexygirlvideomovie animalsex 0401成人交友 情色論壇-情色視訊 34c視訊交友90739 天空交友 go2av-視訊網 蕃薯藤交友 視訊聊天sexygirlsgetfucked辣妹 視訊交友天堂90739 高雄視訊34c正妹 免費視訊34c辣妹微風論壇 月宮貼圖色妹妹嘟嘟情人色網 免費視訊gogo

10:50 AM  
Anonymous Anonymous said...

我們唯一需要恐懼的事,是恐懼本身........................................

8:46 PM  
Anonymous Anonymous said...

85cc片觀看,77美女dvd影片,熊貓貼區,ut網際聊天,一葉情,av,嘟嘟,影音live秀,a片,做愛影片,視訊做愛,美女短片,78論壇,ut聊天,打飛機,a片,免費視訊,免費視訊,成人影院,性愛小說,辣妹視訊,網路交友,捷克論壇,h影片,色咪咪,免費影片85cc,kiss911,後宮,a片,影音視訊聊天,交友,免費聊天,聊天室交友,做愛影片,線上a片,美女影片,免費影片下載,免費聊天室,視訊做愛,美女視訊聊天

10:06 PM  
Anonymous Anonymous said...

正妹日報成人版免費視訊聊天室美女貼圖518人力銀行性感美女線上av免費影片台灣a片王-avdvd免費視訊辣妹聊天室成人 影片明星露點照明星色情文學明星色情寫真明星色情貼圖真真明星色情照片明倫高中正妹明道中學口交日本漫畫卡通排行榜日本漫畫卡通 h 線上觀看日本漫畫色情視訊 辣妹sexdiy影城米克綜合論壇85cc免費聊天室露點girl5320av一葉情貼影色網性愛影片77p2p影片網性愛貼圖sogo論壇xvideos日本sex888免費a片卡通一夜成人聊天室免費影片線上直播ut同志聊天室sm聊天室高雄視訊淫美論壇免費18影片85st免費影片觀看

10:50 PM  
Anonymous Anonymous said...

^^~~輕輕鬆鬆的逛部落格,多謝有您的分享哦~~~........................................

1:13 PM  
Blogger 怡潔 said...

免費成人影騙免費成人電影觀看曼雪兒情色文學成人小說杜雷斯成人貼圖區杜雷斯成人貼圖a片情色成人影片a片無碼圖片a片短片看a片電影城a片圖貼a片網路看a片影片免費看A片線上看a片免費線上影片a片免費影片線上a片免費影片網a片卡通火影忍者a片卡通直播a片孕婦做愛a片未成年a片在線看a片在線觀看a片成人免費觀賞a片免費下載無碼a片免費卡通a片免費成人影片a片免費免下載a片免費貼a片免費貼片a片論壇分享愛情禁忌視訊聊天交友mmshow交友104相親網成人圖片區

11:25 PM  
Anonymous Anonymous said...

成功可招引朋友,挫敗可考驗朋友 ............................................................

11:15 PM  
Blogger 07_TeddyF_Silvey0 said...

人有兩眼一舌,是為了觀察倍於說話的緣故。...........................................................................

8:37 AM  
Blogger 志其志其 said...

人生中最好的禮物就是屬於自己的一部份..................................................

8:37 AM  
Anonymous Anonymous said...

初到貴寶地,拜碼頭!!!請多指教! ........................................

10:05 PM  
Blogger 陳逸群 said...

女傭調教 女生自衛 夫妻交換 大腿內側 夜未眠成 嘟嘟情人 嘟嘟圖片 同志色教 吉澤明步 台中夜店 台北夜店 台灣同志 台灣ki 出包王女 凹凸電影 凌虐俠女 免費女同 免費女傭 免費圖片 免費同志 免費動畫 免費黃色 免費貼影 免費色片 免費dv 免費線上 -qq美美 jp素人 h文小說 辣媽寫真 辣媽哺乳 黃色珍藏 麗的線上 貼圖片區 高雄夜店 視訊kk 西洋美女 電影線上 阿賓小說 阿賓色慾 蓬萊仙山 色片直播 美女自衛 美國色片 美美色網 線上收看 線上動畫 素人寫真 素人大全 短片線上

7:51 AM  
Blogger 穆靜如 said...

^^~~輕輕鬆鬆的逛部落格,多謝有您的分享哦~~~ .................................................................

5:01 AM  
Anonymous Anonymous said...

死亡是悲哀的,但活得不快樂更悲哀。......................................................................

8:10 PM  
Anonymous Anonymous said...

喜歡你的部落格,留言請您繼續加油.................................................................                           

4:31 AM  
Anonymous Anonymous said...

It takes all kinds to make a world.............................................................

9:19 PM  
Anonymous Anonymous said...

It takes all kinds to make a world.............................................................

5:08 PM  
Anonymous Anonymous said...

初次造訪,安安^^..................................................................

7:07 PM  
Anonymous Anonymous said...

偶爾上來逛逛,下次不知是否還有緣再進來,先祝您平安順利!!!............................................................

8:21 PM  
Anonymous Anonymous said...

好的開始並不代表會成功,壞的開始並不代表是失敗............................................................

2:31 AM  
Anonymous Anonymous said...

教育的目的,不在應該思考什麼,而是教吾人怎樣思考............................................................

6:03 PM  
Anonymous Anonymous said...

老天爺賦予了強者的能力,就是要他比弱者多擔待..................................................

2:07 AM  
Anonymous Anonymous said...

不錯唷~我會常常來 >"<............................................................

8:16 PM  
Anonymous Anonymous said...

耐心是一株很苦的植物,但果實卻很甜美。..................................................

5:08 PM  
Anonymous Anonymous said...

成熟,就是有能力適應生活中的模糊。............................................................

6:43 AM  
Anonymous Anonymous said...

耐心是一株很苦的植物,但果實卻很甜美。..................................................

6:44 AM  
Blogger 515152 said...

Learning makes life sweet.

4:16 PM  
Anonymous Anonymous said...

Learning makes life sweet.......................................................................

7:55 PM  
Anonymous Anonymous said...

Learning makes a good man better and ill man worse.............................................................

7:55 PM  
Blogger 建邱勳 said...

只有尋常才幹,但具有不尋常恆心的人,一切皆可獲取................................................

6:27 AM  
Anonymous Anonymous said...

文章不求沽名釣譽,率性就是真的..................................................................

1:36 AM  
Blogger 于庭吳 said...

在莫非定律中有項笨蛋定律:「一個組織中的笨蛋,恆大於等於三分之二。」. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1:31 PM  
Anonymous Anonymous said...

謝謝大大的分享 我會學會反省與寬容 感恩 ∩△∩............................................................

10:38 PM  
Anonymous Anonymous said...

活是一種鍛鍊靈魂的東西..................................................................

10:39 PM  
Anonymous Anonymous said...

知識可以傳授,智慧卻不行。每個人必須成為他自己。..................................................

10:39 PM  
Anonymous Anonymous said...

在莫非定律中有項笨蛋定律:「一個組織中的笨蛋,恆大於等於三分之二。」. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11:19 PM  
Anonymous Anonymous said...

原來這世上能跟你共同領略一個笑話的人竟如此難得......................................................................

4:40 AM  
Anonymous Anonymous said...

生、死、窮、達,不易其操。......................................... ........................

4:51 PM  
Anonymous Anonymous said...

一個人的際遇在第一次總是最深刻的,有時候甚至會讓人的心變成永遠的絕緣。......................................................................

12:54 AM  

Post a Comment

<< Home