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 三人行,必有我師焉 閱讀(340) 評論(0)  編輯  收藏

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


          網站導航:
           
          GitHub |  開源中國社區 |  maven倉庫 |  文件格式轉換 
          主站蜘蛛池模板: 周至县| 蒙自县| 徐闻县| 台南市| 白河县| 浪卡子县| 鄂伦春自治旗| 磐石市| 甘德县| 瑞安市| 德昌县| 保定市| 四平市| 文安县| 高平市| 新宾| 门源| 巴南区| 平武县| 繁昌县| 汾西县| 乡城县| 福建省| 宁海县| 双桥区| 柳河县| 秭归县| 舒兰市| 石门县| 宁陕县| 乌拉特前旗| 上高县| 梁平县| 西丰县| 平阴县| 潜江市| 左贡县| 乌恰县| 承德县| 阿荣旗| 卢龙县|