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

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>
            亚洲欧美日韩一区二区三区在线观看| 一区二区三区产品免费精品久久75 | 日韩一二三区视频| 欧美粗暴jizz性欧美20| 亚洲日本电影| 亚洲人成艺术| 欧美日韩国产精品自在自线| 亚洲无毛电影| 国产精品久久久久久福利一牛影视| 中文精品在线| 欧美亚洲一区二区三区| 精品福利免费观看| 91久久精品国产91性色| 欧美日韩亚洲另类| 欧美一区中文字幕| 久久久久久精| 亚洲神马久久| 久久精品久久99精品久久| 亚洲国产日韩欧美在线99| 一区二区三区蜜桃网| 国产一区深夜福利| 亚洲日本va午夜在线影院| 国产精品你懂得| 美女亚洲精品| 欧美午夜免费| 欧美成人精品一区二区| 欧美视频四区| 欧美国产精品va在线观看| 欧美日韩在线亚洲一区蜜芽| 久久精品一区二区三区不卡| 欧美日本精品| 久久综合亚州| 国产精品女同互慰在线看| 欧美成人综合网站| 国产日韩精品入口| 亚洲风情在线资源站| 国产精品久久久爽爽爽麻豆色哟哟| 蜜桃av一区二区| 国产精品九九| 亚洲精品国产精品国自产观看| 国产日韩欧美a| 亚洲美女毛片| 亚洲欧洲日韩女同| 久久久国产精品一区二区三区| 亚洲女性裸体视频| 欧美剧在线观看| 欧美成人精品在线播放| 国产日韩欧美综合在线| 一区二区三区www| 亚洲精品一线二线三线无人区| 欧美专区18| 欧美一级片一区| 国产精品成人aaaaa网站| 亚洲国产欧美另类丝袜| 在线视频国内自拍亚洲视频| 香蕉久久一区二区不卡无毒影院| 亚洲综合色在线| 欧美日韩一区二区三区在线| 91久久精品国产91性色tv| 伊人男人综合视频网| 久久国产福利| 久久激情网站| 国语精品一区| 久久av二区| 久久亚洲美女| 一区在线播放视频| 久久亚洲一区二区三区四区| 久久婷婷麻豆| 在线观看日韩av电影| 久久漫画官网| 亚洲第一级黄色片| 亚洲精品久久视频| 欧美伦理在线观看| 一本久久青青| 午夜欧美精品| 狠狠综合久久av一区二区老牛| 欧美伊久线香蕉线新在线| 久久久久久久网站| 在线激情影院一区| 欧美激情精品久久久久久| 亚洲国产一区二区视频| 一本色道88久久加勒比精品 | 欧美激情影音先锋| 亚洲精品少妇30p| 亚洲欧美日韩专区| 国产亚洲欧美aaaa| 免费在线欧美视频| 99精品国产在热久久婷婷| 欧美一进一出视频| 在线观看欧美| 欧美日韩福利| 午夜亚洲福利在线老司机| 麻豆成人小视频| 99精品欧美一区二区三区| 国产精品日韩欧美大师| 久久精品日产第一区二区| 亚洲黄网站黄| 欧美一区二区三区在线观看视频| 精品96久久久久久中文字幕无| 免费欧美在线视频| 亚洲在线成人精品| 欧美国产91| 欧美在线一级va免费观看| 亚洲国产乱码最新视频| 国产精品欧美一区喷水| 久久夜色精品国产亚洲aⅴ| 在线一区亚洲| 欧美国产一区二区在线观看| 亚洲欧美日韩中文视频| 亚洲欧洲在线看| 国产日韩欧美中文在线播放| 欧美精品aa| 久久综合国产精品台湾中文娱乐网| 亚洲精选一区| 欧美成人一区二区| 欧美在线你懂的| 亚洲一级二级| 亚洲激情网址| 黑丝一区二区| 国产日韩欧美高清免费| 欧美午夜一区二区| 欧美承认网站| 美女视频黄a大片欧美| 欧美一区二区在线免费观看| 99视频精品在线| 91久久久在线| 欧美激情精品久久久久久| 久久精品综合| 久久精品一区二区三区不卡牛牛| 亚洲一区二区影院| 亚洲视频精品| 夜夜嗨av一区二区三区| 亚洲高清在线观看| 在线观看欧美精品| 一区二区在线观看av| 国产日韩亚洲欧美精品| 国产麻豆日韩欧美久久| 国产精品九九| 国产精品男gay被猛男狂揉视频| 欧美视频你懂的| 欧美天天影院| 国产精品国产三级国产aⅴ无密码| 欧美激情综合在线| 欧美日韩国产丝袜另类| 欧美精品免费看| 欧美日韩国产综合视频在线| 欧美国产日本在线| 欧美—级高清免费播放| 欧美精品手机在线| 欧美视频一区二区三区| 国产精品久久久久久久免费软件 | 欧美视频日韩视频| 欧美午夜宅男影院| 国产老女人精品毛片久久| 国产精品亚洲精品| 国产亚洲激情视频在线| 国产日韩在线亚洲字幕中文| 激情欧美丁香| 亚洲精品视频在线观看免费| 亚洲视频一区在线| 欧美一区二区成人6969| 久久久中精品2020中文| 欧美激情亚洲另类| 一本久道久久综合狠狠爱| 一区二区91| 久久成人精品电影| 欧美 日韩 国产精品免费观看| 欧美精品国产一区二区| 国产精品日韩一区| 经典三级久久| 亚洲少妇一区| 久久久久久久综合色一本| 亚洲国产成人精品久久| 一区二区三区欧美在线观看| 久久成人精品电影| 欧美理论视频| 国产一区二区三区的电影| 在线视频国内自拍亚洲视频| 制服丝袜亚洲播放| 美女视频黄 久久| 一区二区av在线| 久久视频在线免费观看| 欧美日韩一区二区三区在线视频| 国产一区二区日韩精品| 亚洲精品国产精品国自产在线 | 最新中文字幕亚洲| 午夜精品视频| 欧美精品激情blacked18| 国产亚洲精品aa| 一本久久综合亚洲鲁鲁五月天| 久久久久免费视频| 9色精品在线| 久久视频这里只有精品| 国产精品久久久久久久久久直播| 亚洲国产精品美女| 久久av一区二区| 一区二区三区产品免费精品久久75| 久久综合影音| 国模私拍视频一区| 午夜欧美精品久久久久久久|