我的隱式生活(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 閱讀(236) 評論(0)  編輯  收藏 所屬分類: -=Design Pattern=-

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


          網站導航:
           
          主站蜘蛛池模板: 杭州市| 麻江县| 峨眉山市| 丰顺县| 柳州市| 天门市| 类乌齐县| 全州县| 黄龙县| 闻喜县| 昂仁县| 灵寿县| 讷河市| 凤凰县| 甘德县| 泰来县| 四子王旗| 沙湾县| 贡嘎县| 民乐县| 崇阳县| 介休市| 赞皇县| 岳阳市| 莲花县| 阿克陶县| 天津市| 郓城县| 永济市| 衡南县| 托克逊县| 江阴市| 青神县| 朝阳市| 修文县| 祥云县| 景宁| 新乡县| 广德县| 长岛县| 武冈市|