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

C++研究

C++細(xì)節(jié)深度探索及軟件工程

  C++博客 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
  37 隨筆 :: 0 文章 :: 74 評(píng)論 :: 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 常興龍 閱讀(1039) 評(píng)論(4)  編輯 收藏 引用 所屬分類: Design Patterns & Engeering

    評(píng)論

    # re: Implement "GOF's Builder pattern" Using C++(Series of Gof patterns using C++ 4th article) 2007-06-02 20:28 萬(wàn)星星
    用設(shè)計(jì)模式來(lái)設(shè)計(jì)一個(gè)真實(shí)的系統(tǒng),把理想的東西和現(xiàn)實(shí)的世界結(jié)合起來(lái),或許可以學(xué)到更多,成長(zhǎng)更快,理解的更加深刻。
    一個(gè)系統(tǒng)用上4、5個(gè)模式應(yīng)該就比較成功了。  回復(fù)  更多評(píng)論
      

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

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

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

    > 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>
            亚洲三级网站| 99re6热只有精品免费观看| 亚洲女同精品视频| 一区二区三区蜜桃网| 国产精品美女久久福利网站| 亚洲综合第一| 小黄鸭视频精品导航| 国产欧美日韩在线观看| 久久久久久香蕉网| 久久亚洲电影| 中文精品视频| 性视频1819p久久| 曰本成人黄色| 99re6这里只有精品视频在线观看| 欧美视频一区在线| 久久婷婷一区| 欧美巨乳在线| 欧美自拍偷拍午夜视频| 久久在线精品| 亚洲一区图片| 久久亚洲精品伦理| 亚洲影院一区| 久久网站免费| 午夜精品久久久久久久久久久| 欧美亚洲免费| 一区二区三欧美| 香蕉乱码成人久久天堂爱免费 | 亚洲视频欧洲视频| 国产亚洲人成a一在线v站| 亚洲大片av| 国产精品国产三级国产aⅴ浪潮 | 欧美岛国激情| 国产啪精品视频| 亚洲福利视频三区| 国产欧美一级| 亚洲精选91| 亚洲国产精品久久人人爱蜜臀| 一区二区三区精品视频在线观看| 在线日本高清免费不卡| 一区二区三区四区国产| 亚洲欧洲一区二区在线观看 | 亚洲国产日韩一级| 国产午夜精品一区二区三区视频| 亚洲人永久免费| 亚洲第一区在线观看| 午夜一区在线| 午夜精品国产| 欧美日韩伦理在线| 亚洲福利视频专区| 亚洲大片在线| 久久久久国产精品人| 久久精品国产69国产精品亚洲| 欧美视频在线观看免费| 亚洲国产一区二区在线| 亚洲国产欧美日韩| 久久精品视频在线看| 欧美影视一区| 国产欧美日韩视频一区二区| 99伊人成综合| 亚洲一区制服诱惑| 欧美网站在线观看| 一区二区三区|亚洲午夜| 99re这里只有精品6| 欧美国产欧美综合| 亚洲国产精品成人久久综合一区| 亚洲国产精品黑人久久久| 久久久噜噜噜久久人人看| 久久婷婷国产麻豆91天堂| 国产专区综合网| 久久久久久久综合日本| 久久亚裔精品欧美| 亚洲国产二区| 欧美精品一区二区三区在线看午夜| 欧美成人a视频| 亚洲激情在线激情| 欧美激情欧美激情在线五月| 亚洲高清视频中文字幕| 99re6热只有精品免费观看 | 亚洲欧美www| 欧美在线免费播放| 国产午夜精品理论片a级大结局 | 久久精彩视频| 欧美成年视频| 一区二区三区高清在线观看| 欧美日韩在线视频一区二区| 亚洲一区bb| 久久婷婷国产麻豆91天堂| 在线观看成人av| 欧美高清在线| 亚洲免费一在线| 免费看成人av| 亚洲性夜色噜噜噜7777| 国产亚洲精品久久久| 久久三级福利| av成人毛片| 麻豆av一区二区三区久久| 亚洲美女av在线播放| 国产精品美女在线观看| 久久黄色影院| 亚洲乱码日产精品bd| 久久激情婷婷| 亚洲区一区二| 国产精品一级久久久| 老司机成人网| 亚洲男人的天堂在线观看| 免费看av成人| 亚洲欧美精品suv| 亚洲国产一区二区三区高清| 国产精品久久一卡二卡| 久久综合久久综合这里只有精品| 一区二区精品国产| 蜜臀av一级做a爰片久久| 亚洲综合二区| 亚洲精品国产视频| 国产一区二区三区高清在线观看| 欧美精品一区二区三区四区 | 亚洲免费黄色| 另类天堂视频在线观看| 午夜精品一区二区三区在线视| 亚洲激情网站| 国内精品亚洲| 国产精品自拍一区| 欧美日韩在线看| 欧美电影专区| 久久综合九色综合久99| 午夜久久电影网| 国产精品99久久久久久白浆小说| 亚洲国产精品久久久| 久久久噜噜噜久噜久久| 先锋亚洲精品| 亚洲影院色无极综合| 日韩视频精品| 亚洲人成7777| 在线不卡中文字幕| 国内久久婷婷综合| 国产日本欧美一区二区三区在线| 欧美偷拍另类| 欧美午夜电影一区| 欧美日韩成人综合| 欧美女同在线视频| 欧美精品一区二区三区在线播放 | 亚洲欧美日韩精品久久亚洲区| 亚洲欧洲久久| 亚洲三级免费电影| 亚洲免费久久| 99视频有精品| 中日韩男男gay无套| 中文欧美在线视频| 亚洲午夜精品一区二区| 亚洲视频免费在线| 一区二区三区 在线观看视| 在线视频欧美精品| 亚洲欧美日本国产有色| 午夜视频精品| 久久久久久亚洲精品不卡4k岛国| 久久久九九九九| 欧美成人a∨高清免费观看| 欧美福利影院| 欧美性事免费在线观看| 国产免费观看久久| 黄色欧美日韩| 亚洲美女黄网| 先锋影音国产精品| 久久久噜噜噜久久狠狠50岁| 女人香蕉久久**毛片精品| 亚洲国产裸拍裸体视频在线观看乱了中文 | 夜夜嗨av一区二区三区| 亚洲一二三四久久| 欧美在线影院| 欧美国产日韩二区| 国产精品美女一区二区| 黄色日韩网站视频| 一本色道久久精品| 久久国产精品久久国产精品| 欧美暴力喷水在线| 一本色道久久加勒比精品| 午夜在线精品偷拍| 欧美顶级大胆免费视频| 国产精品日韩在线一区| 一区久久精品| 亚洲一区在线观看免费观看电影高清| 欧美资源在线| 亚洲精品午夜精品| 校园春色国产精品| 欧美母乳在线| 伊人春色精品| 亚洲伊人观看| 欧美福利专区| 午夜日本精品| 欧美日韩第一区日日骚| 国内精品久久久久久久果冻传媒 | 9久草视频在线视频精品| 欧美在线视频一区二区| 亚洲国产精品久久久久秋霞影院| 亚洲在线视频免费观看| 欧美国产日本高清在线| 激情文学综合丁香| 欧美在线观看视频一区二区| 亚洲精品韩国| 久久综合网络一区二区|