我的隱式生活(My Implicit Life)

          繼續(xù)搞“對(duì)象”,玩OO.

          首頁 新隨筆 聯(lián)系 聚合 管理
            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) 評(píng)論(0)  編輯  收藏 所屬分類: -=Design Pattern=-

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 景泰县| 璧山县| 惠来县| 盐津县| 珠海市| 曲麻莱县| 福清市| 克拉玛依市| 揭东县| 乌苏市| 喀喇| 青龙| 湘潭市| 平湖市| 嘉祥县| 上高县| 大安市| 璧山县| 东丰县| 北宁市| 开远市| 板桥市| 武穴市| 阜新| 龙游县| 边坝县| 建瓯市| 寿阳县| 西畴县| 晋江市| 天气| 宝清县| 张家川| 津南区| 竹溪县| 彭山县| 永丰县| 芦溪县| 古蔺县| 兴义市| 铜梁县|