日韩欧美在线中字,在线精品国产亚洲,欧美精品三区http://www.aygfsteel.com/coffee3236888/經營屬于我們的咖啡屋zh-cnSun, 06 Jul 2025 23:14:13 GMTSun, 06 Jul 2025 23:14:13 GMT60接口型模型的總結http://www.aygfsteel.com/coffee3236888/articles/301221.html等牛奶的咖啡等牛奶的咖啡Thu, 05 Nov 2009 02:16:00 GMThttp://www.aygfsteel.com/coffee3236888/articles/301221.htmlhttp://www.aygfsteel.com/coffee3236888/comments/301221.htmlhttp://www.aygfsteel.com/coffee3236888/articles/301221.html#Feedback0http://www.aygfsteel.com/coffee3236888/comments/commentRss/301221.htmlhttp://www.aygfsteel.com/coffee3236888/services/trackbacks/301221.html

最近一直在看設計模式方面的書,看完了第一部分接口型模式,下面是我的一些個人理解:

1.        Adapter(適配器)模式

我的理解就是怎樣通過調用已經存在的方法來解決客戶給我們的問題,這里的調用已經存在的方法就是java中的復用代碼,可以通過組合和繼承來實現。換句話說,就是引用或者繼承現有的方法類來適配客戶提供來的問題接口。


2.        Facade(外觀)模式

定位于內部組件和外部客戶程序之間,用于二者間的橋梁。中間類的建立主要面向外部客戶程序,為其提供功能接口,其方法體通過調用內部組件來實現。這樣不僅簡化了調用關系,還在一定程度上達到了“解耦”的效果。


3.        Composite(組合)模式

主要解決客戶在處理單個對象和組合對象上的接口一致性。具體的解決方法就是使用將對象用“樹型結構”組織起來,以達成“部分-整體”的層次結構。通過遍歷(Iterator)整個樹型結構,獲取所有的對象。


4.        Bridge(橋接)模式

進一步的將抽象化與實現化“解耦”。橋梁模式中的所謂脫耦,就是指在一個軟件系統的抽象化和實現化之間使用組合/聚合關系而不是繼承關系,從而使兩者可以相對獨立地變化。

抽象化角色(Abstraction)引用了實現化角色(Implementor)的接口,并且抽象了客戶的功能接口(面向客戶)。

實現化角色(Implementor)抽象出底層操作(面向底層)。



等牛奶的咖啡 2009-11-05 10:16 發表評論
]]>
Composite(組合)模式http://www.aygfsteel.com/coffee3236888/articles/300568.html等牛奶的咖啡等牛奶的咖啡Sun, 01 Nov 2009 06:25:00 GMThttp://www.aygfsteel.com/coffee3236888/articles/300568.htmlhttp://www.aygfsteel.com/coffee3236888/comments/300568.htmlhttp://www.aygfsteel.com/coffee3236888/articles/300568.html#Feedback0http://www.aygfsteel.com/coffee3236888/comments/commentRss/300568.htmlhttp://www.aygfsteel.com/coffee3236888/services/trackbacks/300568.html

Composite(組合)模式

 

意圖在與:讓用戶能夠使用統一的接口處理單個對象以及對象組合

 

理解:



Component類抽象出Leaf類和Composite類共享的公共接口,在Composite類中使用遞歸(iterator)定義關于對象組合的方法。

個人感覺:composite模式就是定義一個統一的接口既可以處理單個對象,又可以處理對象的組合。其中對組合對象的處理又不斷被細分到對其中所包含的單個對象的處理,(使用遞歸遍歷各個結點)。



等牛奶的咖啡 2009-11-01 14:25 發表評論
]]>
Short類及其方法的分析http://www.aygfsteel.com/coffee3236888/articles/300412.html等牛奶的咖啡等牛奶的咖啡Fri, 30 Oct 2009 12:29:00 GMThttp://www.aygfsteel.com/coffee3236888/articles/300412.htmlhttp://www.aygfsteel.com/coffee3236888/comments/300412.htmlhttp://www.aygfsteel.com/coffee3236888/articles/300412.html#Feedback0http://www.aygfsteel.com/coffee3236888/comments/commentRss/300412.htmlhttp://www.aygfsteel.com/coffee3236888/services/trackbacks/300412.html  1 /**   2  * 提供程序設計的基礎類   3  */ ...  閱讀全文

等牛奶的咖啡 2009-10-30 20:29 發表評論
]]>
Byte類及其方法的分析http://www.aygfsteel.com/coffee3236888/articles/300300.html等牛奶的咖啡等牛奶的咖啡Fri, 30 Oct 2009 01:16:00 GMThttp://www.aygfsteel.com/coffee3236888/articles/300300.htmlhttp://www.aygfsteel.com/coffee3236888/comments/300300.htmlhttp://www.aygfsteel.com/coffee3236888/articles/300300.html#Feedback0http://www.aygfsteel.com/coffee3236888/comments/commentRss/300300.htmlhttp://www.aygfsteel.com/coffee3236888/services/trackbacks/300300.html  1 /**   2  * 提供程序設計的基礎類   3  */ ...  閱讀全文

等牛奶的咖啡 2009-10-30 09:16 發表評論
]]>
Number類及其方法的分析http://www.aygfsteel.com/coffee3236888/articles/300297.html等牛奶的咖啡等牛奶的咖啡Fri, 30 Oct 2009 01:04:00 GMThttp://www.aygfsteel.com/coffee3236888/articles/300297.htmlhttp://www.aygfsteel.com/coffee3236888/comments/300297.htmlhttp://www.aygfsteel.com/coffee3236888/articles/300297.html#Feedback0http://www.aygfsteel.com/coffee3236888/comments/commentRss/300297.htmlhttp://www.aygfsteel.com/coffee3236888/services/trackbacks/300297.html 1 /**
 2  * 提供程序設計的基礎
 3  */
 4 package java.lang;
 5 
 6 /**
 7  * 抽象類 Number
 8  * BigDecimal、BigInteger、Byte、Double、Float、Integer、Long 和 Short 類的超類
 9  */
10 public abstract class Number implements java.io.Serializable {
11 
12     /** 表明類的不同版本間的兼容性 */
13     private static final long serialVersionUID = -8742448824652078965L;
14 
15     /**
16      * 以 int 形式返回指定的數值
17      */
18     public abstract int intValue();
19 
20     /**
21      * 以 long 形式返回指定的數值
22      */
23     public abstract long longValue();
24 
25     /**
26      * 以 float 形式返回指定的數值
27      */
28     public abstract float floatValue();
29 
30     /**
31      * 以 double 形式返回指定的數值
32      */
33     public abstract double doubleValue();
34 
35     /**
36      * 以 byte 形式返回指定的數值
37      */
38     public byte byteValue() {
39         return (byte) intValue();
40     }
41 
42     /**
43      * 以 short 形式返回指定的數值
44      */
45     public short shortValue() {
46         return (short) intValue();
47     }
48 }
49 

等牛奶的咖啡 2009-10-30 09:04 發表評論
]]>
Facade(外觀)模式http://www.aygfsteel.com/coffee3236888/articles/300251.html等牛奶的咖啡等牛奶的咖啡Thu, 29 Oct 2009 11:48:00 GMThttp://www.aygfsteel.com/coffee3236888/articles/300251.htmlhttp://www.aygfsteel.com/coffee3236888/comments/300251.htmlhttp://www.aygfsteel.com/coffee3236888/articles/300251.html#Feedback0http://www.aygfsteel.com/coffee3236888/comments/commentRss/300251.htmlhttp://www.aygfsteel.com/coffee3236888/services/trackbacks/300251.html

Facade(外觀)模式

 

旨在提供一個接口,使子系統更加容易使用

 

Before Facade

 


Using Facade

 

Facade模式 與 Adapter模式

相似:為既存的類提供界面統一的接口,以供外部類調用

不同:Facade模式的目的是簡化調用關系

     Adapter模式是為不同的模塊/子系統提供一個統一的接口(支持多態),旨在將一個或多個已經存在的不統一的接口轉化為另一個統一的接口



等牛奶的咖啡 2009-10-29 19:48 發表評論
]]>
Adapter(適配器)模式http://www.aygfsteel.com/coffee3236888/articles/300225.html等牛奶的咖啡等牛奶的咖啡Thu, 29 Oct 2009 10:37:00 GMThttp://www.aygfsteel.com/coffee3236888/articles/300225.htmlhttp://www.aygfsteel.com/coffee3236888/comments/300225.htmlhttp://www.aygfsteel.com/coffee3236888/articles/300225.html#Feedback0http://www.aygfsteel.com/coffee3236888/comments/commentRss/300225.htmlhttp://www.aygfsteel.com/coffee3236888/services/trackbacks/300225.html

Adapter(適配器)模式

 

旨在保留現有類所提供的服務,向客戶提供接口,以滿足客戶的期望

即存在方法類,并可以提供給客戶的需求接口

 

理解1.類適配器

通過繼承得到已存方法類的方法使用權去實現所需的客戶接口

 

理解2.對象適配器

擴展一個客戶所需的目標類,并把它委派給一個現有的方法類去實現


區別:

   類適配器是擴展一個現有的類,并實現一個目標接口

   對象適配器是擴展一個目標類,并把它委派給一個現有的類



等牛奶的咖啡 2009-10-29 18:37 發表評論
]]>
關于Object類方法的分析http://www.aygfsteel.com/coffee3236888/articles/299981.html等牛奶的咖啡等牛奶的咖啡Tue, 27 Oct 2009 13:50:00 GMThttp://www.aygfsteel.com/coffee3236888/articles/299981.htmlhttp://www.aygfsteel.com/coffee3236888/comments/299981.htmlhttp://www.aygfsteel.com/coffee3236888/articles/299981.html#Feedback0http://www.aygfsteel.com/coffee3236888/comments/commentRss/299981.htmlhttp://www.aygfsteel.com/coffee3236888/services/trackbacks/299981.html  1 /**
  2  * 提供程序設計的基礎類
  3  */
  4 package java.lang;
  5 
  6 /**
  7  * 類層次結構的根類
  8  */
  9 public class Object {
 10 
 11     /**
 12      * 注冊一些本地方法,具體實現在DLL中
 13      */
 14     private static native void registerNatives();
 15 
 16     static {
 17         registerNatives();
 18     }
 19 
 20     /**
 21      * 返回此 Object 的運行時類
 22      * 不可以被重寫
 23      */
 24     public final native Class<?> getClass();
 25 
 26     /**
 27      * 返回對象的哈希碼值
 28      */
 29     public native int hashCode();
 30 
 31     /**
 32      * 指示其他某個對象是否與此對象相等,比較的是對象的引用
 33      * 有些子類會重寫該方法,以使其具有比較對象內容的功能
 34      * 子類在重寫該方法的時候,通常要重寫 hashCode() 方法
 35      */
 36     public boolean equals(Object obj) {
 37         return (this == obj);
 38     }
 39 
 40     /**
 41      * 創建并返回此對象的一個副本
 42      * 這個方法被定義為 protected ,調用此方法需要實現 Cloneable 接口
 43      * 否則拋出異常 CloneNotSupportedException
 44      */
 45     protected native Object clone() throws CloneNotSupportedException;
 46 
 47     /**
 48      * 返回該對象的字符串表示,類名@對象哈希碼的無符號十六進制
 49      */
 50     public String toString() {
 51         return getClass().getName() + "@" + Integer.toHexString(hashCode());
 52     }
 53 
 54     /**
 55      * 喚醒在此對象監視器上等待的單個線程
 56      * 不可以被重寫
 57      */
 58     public final native void notify();
 59 
 60     /**
 61      * 喚醒在此對象監視器上等待的所有線程
 62      * 不可以被重寫
 63      */
 64     public final native void notifyAll();
 65 
 66     /**
 67      * 在其他線程調用此對象的 notify()方法或notifyAll() 方法,或者超過指定的時間量前,導致當前線程等待
 68      * 不可以被重寫
 69      */
 70     public final native void wait(long timeout) throws InterruptedException;
 71 
 72     /**
 73      * 在其他線程調用此對象的 notify() 方法或 notifyAll()
 74      * 方法,或者其他某個線程中斷當前線程,或者已超過某個實際時間量前,導致當前線程等待
 75      * 不可以被重寫
 76      */
 77     public final void wait(long timeout, int nanos) throws InterruptedException {
 78         if (timeout < 0) {
 79             throw new IllegalArgumentException("timeout value is negative");
 80         }
 81 
 82         if (nanos < 0 || nanos > 999999) {
 83             throw new IllegalArgumentException(
 84                     "nanosecond timeout value out of range");
 85         }
 86 
 87         if (nanos >= 500000 || (nanos != 0 && timeout == 0)) {
 88             timeout++;
 89         }
 90 
 91         wait(timeout);
 92     }
 93 
 94     /**
 95      * 在其他線程調用此對象的 notify() 方法或 notifyAll() 方法前,導致當前線程等待
 96      * 不可以被重寫
 97      */
 98     public final void wait() throws InterruptedException {
 99         wait(0);
100     }
101 
102     /**
103      * 對象的垃圾回收器調用此方法,具體實現的方法體由子類重寫此方法
104      */
105     protected void finalize() throws Throwable {
106     }
107 }
108 

等牛奶的咖啡 2009-10-27 21:50 發表評論
]]>
主站蜘蛛池模板: 海城市| 博罗县| 鹤峰县| 翁源县| 岳普湖县| 中卫市| 金门县| 荥经县| 紫阳县| 固阳县| 菏泽市| 寻乌县| 太仓市| 扎赉特旗| 盐边县| 桑植县| 无为县| 新沂市| 乌鲁木齐县| 宿松县| 瑞金市| 循化| 泸西县| 南召县| 河北区| 安塞县| 云和县| 游戏| 雅安市| 岢岚县| 陇南市| 扶风县| 公主岭市| 射洪县| 镇安县| 云林县| 寻甸| 锡林郭勒盟| 高州市| 会同县| 施秉县|