青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

C++研究

C++細節深度探索及軟件工程

  C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
  37 隨筆 :: 0 文章 :: 74 評論 :: 0 Trackbacks

This is the 4Th Arcticle: Builder PATTERN

Separates the construction of a complex object from its representation so that the same construction process can create different representations.  --Gof

 The builder pattern can separate the representation and construction easily , while you building a big-pang object , and some of the object itself  is

diversified and  could be build separately , considering this pattern.

Participants:

  • Builder.
    • specifies an abstract interface for creating parts of a Product object
  • ConcreteBuilder.
    • constructs and assembles parts of the product by implementing the Builder interface
    • defines and keeps track of the representation it creates
    • provides an interface for retrieving the product
  • Director.
    • constructs an object using the Builder interface
  • Product.
    • represents the complex object under construction. ConcreteBuilder builds the product's internal representation and defines the process by which it's assembled
    • includes classes that define the constituent parts, including interfaces for assembling the parts into the final result 


  •  The diagram goes here:


    Code is the most clearly lauguage for out programmers , so  I will use code to expree this pattern clearly as follows:

      1
      2/* this is the diversfied part*/
      3
      4//abstract
      5class House
      6{
      7
      8}
    ;
      9//abstract
     10class Door
     11{
     12
     13}
    ;
     14
     15//concrete, transformation
     16class FeDoor: public Door
     17{
     18
     19}
    ;
     20//concreate, transformation
     21class WoodDoor: public Door
     22{
     23
     24}
    ;
     25
     26//abstract
     27class Window
     28{
     29
     30}
    ;
     31//concreate , transformation
     32class FeWindow :public Window
     33{
     34
     35}
    ;
     36//concreate, transformation
     37class WoodWindow :public Window
     38{
     39
     40}
    ;
     41
     42/*this is the builder the stable part*/
     43class Builder
     44{
     45
     46protected:
     47    //build every part here
     48    virtual  void BuildeDoor();
     49    virtual  void BuildeWindow();
     50    virtual void  BuildFloor();
     51    //to get the result
     52public:
     53    virtual void GetHouse();
     54    
     55}

     56
     57class FeHouseBuilder :public Builder
     58{
     59public:
     60    GetHouse()
     61    {
     62        return /*window + door */
     63    }

     64protected:
     65    void BuildeDoor()
     66    {
     67       
     68        aDoor=new FeDoor();
     69    }

     70    void BuildWindow()
     71    {
     72        aRedWindow=new FeWindow();
     73    }

     74private:
     75    Window aWindow;
     76    Door aDoor;
     77
     78}

     79
     80class WoodHouseBuilder :public Builder
     81{
     82public:
     83    House GetHouse()
     84    {
     85        return /*window + door */
     86    }

     87protected:
     88    void BuildeDoor()
     89    {
     90       
     91        aDoor=new WoodDoor(); //can change 
     92    }

     93    void BuildWindow()
     94    {
     95        aRedWindow=new WoodWindow(); //can change too
     96    }

     97private:
     98    Window aWindow;
     99    Door aDoor;
    100
    101}

    102
    103class Director
    104{
    105public:
    106    //Create a house that has two doors and a window , this is the creator part , It's usually Stable too
    107    static House Construct(Builder builder)
    108    {
    109       builder.BuildeDoor();
    110       builder.BuildeDoor();
    111       builder.BuildeWindow();
    112
    113       return builder.GetHouse();
    114    }

    115
    116}
    ;
    117
    118//client
    119int main(int argc , char * argv[])
    120{
    121   //read the config file 
    122   //build a fe House with two doors and a window
    123    Director::Construct(new FeHouseBuilder());
    124   //builder a wood house with two doors and a window 
    125    Director::Construct(new WoodHouseBuilder());
    126
    127    /*two doors and a window is stable , and  the house 's architecture is stable too ,but the material*/
    128
    129}


     1-40  is the diversification , the house's architecture is stable , you create a mixed house easily if you like ,  simply add a class called mixedhouseBuidler and use the right part(like the FeDoor  and WoodDoor ) to create the mixed house ,and use the mixedHouseBuilder to builde you work.

    simple and practible!
    posted on 2007-06-02 17:34 常興龍 閱讀(1029) 評論(4)  編輯 收藏 引用 所屬分類: Design Patterns & Engeering

    評論

    # re: Implement "GOF's Builder pattern" Using C++(Series of Gof patterns using C++ 4th article) 2007-06-02 20:28 萬星星
    用設計模式來設計一個真實的系統,把理想的東西和現實的世界結合起來,或許可以學到更多,成長更快,理解的更加深刻。
    一個系統用上4、5個模式應該就比較成功了。  回復  更多評論
      

    # re: Implement "GOF's Builder pattern" Using C++(Series of Gof patterns using C++ 4th article) 2007-06-03 14:12 常興龍
    設計模式,相似的代碼很可能是不同的模式,不同的代碼很可能是相同的模式思想。萬變不離其蹤,這里只給了一種自我思考的例子。放入工程中別人很難看清楚是什么,因而不能發表其也許更好的見解。多謝評論!  回復  更多評論
      

    # re: Implement "GOF's Builder pattern" Using C++(Series of Gof patterns using C++ 4th article) 2007-06-04 13:58 picasa
    誰能翻一下  回復  更多評論
      

    # re: Implement "GOF's Builder pattern" Using C++(Series of Gof patterns using C++ 4th article) 2007-09-28 20:12 馬承志
    主人的想法非常好,當然如果能在現實的項目中使用模式解決問題才是根本.不過通過C++完成所有的模式也是一種實踐.可以加深我們的理解.非常支持你的做法,不過我現在覺得重構到模式可能更能解決實際問題.你的目標非常具體,是我的學習榜樣.希望我們以后能夠多交流  回復  更多評論
      

    > hi的博客
    青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美一区精品| 久久久久国色av免费观看性色| 亚洲伦理在线| 亚洲精选91| 欧美日韩国产成人精品| 亚洲国产日韩欧美在线图片| 国产有码一区二区| 亚久久调教视频| 久久激情视频久久| 国产日韩欧美a| 欧美中文在线观看国产| 美女脱光内衣内裤视频久久影院| 韩日精品中文字幕| 欧美成人免费小视频| 亚洲精品一区二| 亚洲欧美日韩第一区| 国产一区二区三区免费不卡| 久久久亚洲精品一区二区三区 | 久久久一区二区三区| 精品av久久707| 欧美激情一区二区三级高清视频 | 欧美中文在线视频| 牛牛影视久久网| 亚洲卡通欧美制服中文| 亚洲欧美国产制服动漫| 亚洲久色影视| 久久国产天堂福利天堂| 黄色工厂这里只有精品| 免费日韩精品中文字幕视频在线| 亚洲精品一区二区三区福利| 欧美永久精品| 99re热精品| 国产三级欧美三级| 欧美国产精品v| 欧美一区二区三区精品| 亚洲国产精品激情在线观看| 亚洲综合第一页| 在线观看欧美激情| 国产精品久久国产三级国电话系列 | 亚洲精品乱码久久久久久久久| 欧美午夜www高清视频| 久久久久久久久久久一区| 日韩视频在线观看一区二区| 久久久91精品| 亚洲影视综合| 一区二区三区高清| 亚洲第一主播视频| 国产一区二区高清不卡| 欧美精品午夜| 久久精品夜色噜噜亚洲a∨| 日韩视频在线免费| 亚洲激情视频在线播放| 久久精品亚洲| 欧美一区二区三区久久精品| 一区二区三区欧美成人| 亚洲精品一二三区| 亚洲国产女人aaa毛片在线| 国产日韩视频一区二区三区| 欧美日韩亚洲一区二区三区| 免费成人性网站| 久久久久久久久久久成人| 亚洲欧美网站| 亚洲欧美另类国产| 亚洲一区二区三区四区在线观看 | 亚洲在线第一页| 亚洲激情视频| 亚洲国产午夜| 欧美亚洲一区三区| 久久久久久夜| 男人的天堂亚洲| 亚洲性视频h| 亚洲日本黄色| 欧美国产精品久久| 另类专区欧美制服同性| 久久久久久久999精品视频| 亚洲人成亚洲人成在线观看| 在线日韩av片| 国模一区二区三区| 国产原创一区二区| 精品动漫一区| 在线免费不卡视频| 伊人狠狠色丁香综合尤物| 国内外成人在线视频| 国产在线视频欧美| 亚洲国产91| 亚洲国产高清一区二区三区| 在线看日韩欧美| 日韩一区二区精品视频| 日韩亚洲欧美成人一区| 亚洲一区国产视频| 小黄鸭精品aⅴ导航网站入口| 午夜欧美精品| 亚洲欧美制服另类日韩| 欧美在线观看一区二区| 久久婷婷成人综合色| 欧美成人高清| 亚洲人成网站在线观看播放| 一区二区欧美在线| 欧美一区二区在线| 免费一级欧美片在线观看| 欧美激情中文字幕乱码免费| 欧美色大人视频| 亚洲一区免费网站| 久久久青草婷婷精品综合日韩 | 在线视频你懂得一区二区三区| 午夜国产一区| 欧美激情久久久久| 亚洲一区二区黄色| 欧美成人网在线| 国产欧美精品在线| 日韩视频一区二区三区在线播放免费观看| 亚洲免费网址| 欧美福利一区| 亚洲天天影视| 欧美久久久久久蜜桃| 国产亚洲亚洲| 午夜精品美女自拍福到在线| 牛牛国产精品| 午夜在线成人av| 久久久久久日产精品| 亚洲精品在线免费| 久久婷婷蜜乳一本欲蜜臀| 国产女优一区| 中文精品在线| 亚洲人在线视频| 两个人的视频www国产精品| 国产精品入口| 亚洲一区二区三区四区五区黄| 亚洲大片在线| 久久午夜色播影院免费高清| 国产精品午夜在线| 亚洲视频精品在线| 亚洲国产精品热久久| 久久久噜噜噜久久久| 国产精品女主播在线观看| 亚洲精品日日夜夜| 每日更新成人在线视频| 亚洲影院免费观看| 国产精品欧美久久久久无广告| 亚洲国产日韩欧美在线图片 | 午夜精品一区二区三区电影天堂| 欧美韩国一区| 牛人盗摄一区二区三区视频| 黄色日韩网站| 亚洲欧美一区二区激情| 亚洲国产精品久久久久秋霞影院| 欧美 日韩 国产在线| 91久久亚洲| 亚洲激情电影在线| 欧美理论在线播放| 亚洲视频久久| 亚洲桃色在线一区| 国产精品久久久一区二区三区| 亚洲字幕一区二区| 午夜欧美精品| 狠狠爱成人网| 欧美国产先锋| 欧美激情一区在线观看| 99热精品在线观看| 日韩五码在线| 国产视频亚洲精品| 女人香蕉久久**毛片精品| 免费不卡中文字幕视频| 亚洲特黄一级片| 欧美一区二区免费观在线| 亚洲大片一区二区三区| 亚洲欧洲一区二区三区久久| 国产精品v欧美精品v日韩 | 欧美美女操人视频| 亚洲欧美日韩中文播放| 欧美亚洲一区二区在线| 亚洲国产精品久久久久婷婷老年 | 久久xxxx| 亚洲精品在线观看免费| 亚洲视频网站在线观看| 欧美中文字幕| 亚洲日本中文| 亚洲欧美日韩国产综合在线| 在线免费观看日本欧美| 99热这里只有精品8| 国产婷婷色一区二区三区| 久久全国免费视频| 亚洲国产女人aaa毛片在线| 99这里只有久久精品视频| 国产无一区二区| 亚洲精品国产精品乱码不99按摩 | 亚洲福利在线视频| 一本色道久久88综合亚洲精品ⅰ | 久久一区二区三区超碰国产精品| 99视频精品免费观看| 午夜在线一区二区| 亚洲最新在线| 久久视频一区| 久久国产精品一区二区| 欧美日韩国产精品成人| 免费一级欧美片在线播放| 国产精品欧美激情| 日韩视频免费观看高清完整版| 亚洲福利视频网| 久久久精品一区|