<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                #### 橋接模式 橋接模式是[軟件設計模式](https://zh.wikipedia.org/wiki/%E8%BB%9F%E4%BB%B6%E8%A8%AD%E8%A8%88%E6%A8%A1%E5%BC%8F)中最復雜的模式之一,它把事物對象和其具體行為、具體特征分離開來,使它們可以各自獨立的變化。事物對象僅是一個抽象的概念。如“圓形”、“三角形”歸于抽象的“形狀”之下,而“畫圓”、“畫三角”歸于實現行為的“畫圖”類之下,然后由“形狀”調用“畫圖”。 理解橋接模式,重點需要理解如何將抽象化(Abstraction)與實現化(Implementation)脫耦,使得二者可以獨立地變化。橋接模式提高了系統的可擴充性,在兩個變化維度中任意擴展一個維度,都不需要修改原有系統。 `角色:` Abstraction:定義抽象的接口,該接口包含實現具體行為、具體特征的Implementor接口 Refined Abstraction:抽象接口Abstraction的子類,依舊是一個抽象的事物名 Implementor:定義具體行為、具體特征的應用接口 ConcreteImplementor:實現Implementor接口 `UML類圖` ![此處輸入圖片的描述](https://doc.shiyanlou.com/document-uid108299labid2297timestamp1486371373063.png) `示例代碼``DrawingAPI.class.php` ~~~php <?php interface DrawingAPI{ public function drawCircle($x,$y,$radius); } /** * drawAPI1 */ class DrawingAPI1 implements DrawingAPI { public function drawCircle($x,$y,$radius) { echo "API1.circle at (".$x.','.$y.') radius '.$radius.'<br>'; } } /** * drawAPI2 */ class DrawingAPI2 implements DrawingAPI { public function drawCircle($x,$y,$radius) { echo "API2.circle at (".$x.','.$y.') radius '.$radius.'<br>'; } } /** *shape接口 */ interface Shape{ public function draw(); public function resize($radius); } class CircleShape implements Shape { private $x; private $y; private $radius; private $drawingAPI; function __construct($x,$y,$radius,DrawingAPI $drawingAPI) { $this->x = $x; $this->y = $y; $this->radius = $radius; $this->drawingAPI = $drawingAPI; } public function draw() { $this->drawingAPI->drawCircle($this->x,$this->y,$this->radius); } public function resize($radius) { $this->radius = $radius; } } $shape1 = new CircleShape(1,2,4,new DrawingAPI1()); $shape2 = new CircleShape(1,2,4,new DrawingAPI2()); $shape1->draw(); $shape2->draw(); $shape1->resize(10); $shape1->draw(); ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看