Feeling

              三人行,必有我師焉

             ::  :: 新隨筆 :: 聯系 ::  :: 管理 ::
            185 隨筆 :: 0 文章 :: 392 評論 :: 0 Trackbacks

          comparator 

          Decorator Pattern and Adapter Pattern have the same alias name: wrapper. But they face different aspects. Decorator pattern changes the object function, but the adapter pattern changes the interface.

          The typical decorator pattern is the java OutputStream, you can use the BufferedOutputStream to wrap it, then get the extra function.
          The typical adapter pattern in the BIRT is the ElementAdapter, it can convert any object to an other object.

          Decorator pattern must extend the class which you want to wrap, but the adapter class must implements the interface using by the client.


          FlyWeight pattern extracts the same part of some different objects, and the part doesn't be changed when these objects changed. String class uses the FlyWeight pattern, jface 
          ImageRegistry also uses it. 
          FlyWeight can have a interface to get external data, and change the external data's status, but FlyWeight internal status shouldn't be changed.

          The Collections.sort() method implementation contains template method design pattern and strategy design pattern, but it doesn't contain the visitor design pattern. The Collections.sort() method uses the merge sort algorithm, you can't change it, but you can change the comparator logic, it's one step of the sort algorithm. So it's a template method pattern, but not a classic implementation, it uses the callback method to implement the pattern, but not extending the parent template class. The comparator class use the strategy design pattern, it not a visitor pattern, visitor pattern have a accept method to operate the element to deal some logic. 



          posted on 2012-11-14 00:22 三人行,必有我師焉 閱讀(335) 評論(0)  編輯  收藏

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


          網站導航:
           
          GitHub |  開源中國社區 |  maven倉庫 |  文件格式轉換 
          主站蜘蛛池模板: 交口县| 延安市| 循化| 贺兰县| 奉节县| 民县| 思茅市| 海阳市| 德保县| 泊头市| 海宁市| 万安县| 繁昌县| 五大连池市| 德庆县| 金阳县| 惠水县| 盐津县| 兴山县| 平江县| 黄山市| 延庆县| 昆明市| 肇东市| 江口县| 遂川县| 察雅县| 克山县| 祥云县| 额济纳旗| 柯坪县| 天全县| 双江| 南京市| 林州市| 庆阳市| 普兰县| 格尔木市| 阜平县| 普兰店市| 新建县|