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

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>
            一本大道久久a久久精品综合| 亚洲日本电影| 香蕉亚洲视频| 亚洲在线电影| 国产在线欧美日韩| 欧美福利在线观看| 欧美成人综合网站| 亚洲视频在线观看视频| 亚洲一区在线直播| 一区二区在线不卡| 亚洲日本中文| 国产精品亚洲精品| 久久裸体视频| 欧美国产日韩一区二区三区| 伊人久久大香线蕉综合热线| 久久久久99| 欧美成人免费在线视频| 亚洲在线免费| 久久久久久尹人网香蕉| 日韩亚洲欧美成人一区| 亚洲一区二区免费视频| 1024成人网色www| 亚洲精品一区二区三区福利| 国产精品日韩久久久久| 久久久久久网站| 欧美成人精品在线观看| 欧美一区三区三区高中清蜜桃| 久久精品综合| 亚洲欧美影音先锋| 欧美成人激情视频| 久久精品国产96久久久香蕉| 欧美r片在线| 久久99伊人| 欧美日本国产| 老司机成人网| 国产精品乱码妇女bbbb| 欧美激情视频给我| 国产网站欧美日韩免费精品在线观看| 欧美电影美腿模特1979在线看| 欧美午夜性色大片在线观看| 亚洲大片在线观看| 激情婷婷久久| 午夜精品福利在线观看| 亚洲午夜电影在线观看| 免费观看国产成人| 久久伊伊香蕉| 国产日韩精品综合网站| 一区二区三区**美女毛片| 亚洲免费高清| 欧美本精品男人aⅴ天堂| 久久久久国产精品午夜一区| 欧美午夜片在线免费观看| 亚洲福利视频二区| 亚洲国产精品久久久久| 久久九九久精品国产免费直播| 亚洲欧美精品在线观看| 欧美性猛交一区二区三区精品| 亚洲第一天堂av| 亚洲高清123| 久久一区国产| 欧美成人激情在线| 在线观看精品一区| 老司机凹凸av亚洲导航| 美女黄网久久| 亚洲成人在线观看视频| 久久蜜桃av一区精品变态类天堂| 久久亚洲综合色| 一区免费观看视频| 狂野欧美激情性xxxx欧美| 免费久久精品视频| 亚洲国产精品美女| 欧美第一黄色网| 亚洲茄子视频| 亚洲影视在线播放| 国产精品美女久久久| 亚洲男人影院| 久久综合九色| 亚洲精品美女91| 欧美午夜免费电影| 欧美制服丝袜| 亚洲第一狼人社区| 亚洲视频www| 国产视频久久久久| 久色婷婷小香蕉久久| 日韩视频精品在线观看| 性18欧美另类| 国产在线视频欧美| 欧美国产日韩亚洲一区| 这里只有精品视频在线| 久久久久久伊人| 亚洲免费观看| 国产欧美日韩一区二区三区| 久久久久久九九九九| 91久久精品美女| 性做久久久久久免费观看欧美| 韩国久久久久| 欧美日韩午夜在线视频| 欧美一级视频一区二区| 欧美激情影音先锋| 午夜精品久久99蜜桃的功能介绍| 国产主播精品在线| 欧美日韩视频在线第一区| 欧美在线免费| 99精品国产高清一区二区| 久久乐国产精品| 亚洲天堂偷拍| 亚洲国产cao| 国产欧美一区二区视频| 欧美国产日韩a欧美在线观看| 亚洲一区二区三区精品视频| 亚洲高清在线| 久久米奇亚洲| 性色av香蕉一区二区| 亚洲免费高清| 在线观看三级视频欧美| 国产欧美日韩高清| 欧美天堂在线观看| 免费观看日韩av| 欧美一区深夜视频| 亚洲天堂成人| 亚洲日本中文字幕区| 免费人成网站在线观看欧美高清| 亚洲一区在线视频| 一区二区三区精品视频| 亚洲高清视频中文字幕| 国产午夜精品全部视频在线播放| 欧美日韩一区三区| 欧美激情亚洲一区| 麻豆精品一区二区综合av | 91久久国产综合久久蜜月精品| 亚洲第一精品夜夜躁人人躁| 久久国内精品自在自线400部| 国产精品99久久久久久有的能看| 亚洲国产成人久久综合| 激情丁香综合| 国产一区成人| 国产原创一区二区| 国产日产精品一区二区三区四区的观看方式 | 亚洲欧美日韩精品综合在线观看| 亚洲精品一区在线观看| 亚洲激情视频在线| 亚洲三级免费电影| 亚洲美女视频在线观看| 亚洲精品欧美极品| 亚洲少妇诱惑| 亚洲女人小视频在线观看| 亚洲与欧洲av电影| 欧美在线短视频| 久久久久国产成人精品亚洲午夜| 欧美在线视频一区二区三区| 久久精品理论片| 美女主播视频一区| 欧美韩日一区二区| 欧美色一级片| 国产精品亚洲视频| 黄色成人在线网站| 亚洲精品欧美日韩专区| 夜夜嗨av一区二区三区四区| 亚洲自拍偷拍福利| 久久成人免费网| 免费观看一区| 亚洲人成在线影院| 亚洲一区二区在线看| 久久久久久久欧美精品| 欧美激情bt| 国产精品毛片高清在线完整版| 国产亚洲欧美日韩精品| 在线观看亚洲a| 99亚洲精品| 久久久久久久999精品视频| 欧美阿v一级看视频| 亚洲区一区二| 欧美一区二区高清在线观看| 久久久久免费视频| 欧美日韩综合另类| 国产亚洲永久域名| 99精品视频免费观看视频| 亚洲欧美日韩一区二区在线 | 99国产精品久久久久久久久久| 亚洲欧美国产一区二区三区| 欧美777四色影视在线| 国产精品亚洲аv天堂网| 亚洲欧洲免费视频| 欧美专区在线播放| 亚洲精品国久久99热| 欧美一区=区| 欧美午夜一区二区三区免费大片| 国产专区欧美专区| 亚洲一级高清| 欧美激情一区在线观看| 欧美亚洲在线| 国产精品国产三级国产专播品爱网| 国产一区二区三区四区三区四| 一区二区三区高清视频在线观看| 美日韩免费视频| 亚洲自拍偷拍福利| 欧美日本三区| 亚洲国产综合视频在线观看 | 亚洲国产毛片完整版| 久久国产视频网|