我的隱式生活(My Implicit Life)

          繼續搞“對象”,玩OO.

          首頁 新隨筆 聯系 聚合 管理
            11 Posts :: 1 Stories :: 39 Comments :: 0 Trackbacks

          The interfaces that are concerned with holding objects are Collection, List, Set, and Map.Ideally, you’ll write most of your code to talk to these interfaces, and the only place where you’ll specify the precise type you’re using is at the point of creation. So you can create a List like this:

          List x = new LinkedList();


          Of course, you can also decide to make x a LinkedList (instead of a generic List)and carry the precise type information around with x. The beauty (and the intent) of using the interface is that if you decide you want to change your implementation, all you need to do is change it at the point of creation, like this:

          List x = new ArrayList();


          The rest of your code can remain untouched (some of this genericity can also be achieved with iterators).

          操。以前怎么就沒人這么講過呢。媽的,都是垃圾!

          posted on 2006-09-01 17:16 marco 閱讀(229) 評論(0)  編輯  收藏 所屬分類: -=Design Pattern=-

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 百色市| 远安县| 泰来县| 杭州市| 钦州市| 渭南市| 苏尼特左旗| 枣庄市| 嘉善县| 连城县| 嘉兴市| 屏东市| 安泽县| 潞西市| 瑞昌市| 太保市| 陆河县| 白沙| 大新县| 海门市| 镇原县| 吉安县| 小金县| 盐山县| 滕州市| 施秉县| 延庆县| 仙居县| 南丰县| 喜德县| 西畴县| 阜新| 洪洞县| 宁晋县| 凌海市| 扎赉特旗| 克什克腾旗| 栖霞市| 藁城市| 且末县| 弥勒县|