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

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>
            亚洲一级在线观看| 亚洲精品一区二区在线观看| 国产精品午夜国产小视频| 亚洲午夜精品一区二区三区他趣| 香蕉久久夜色精品| 国产欧美一区二区三区沐欲 | 免费观看日韩av| 亚洲黄一区二区三区| 亚洲美女黄色| 国产精品欧美激情| 噜噜噜躁狠狠躁狠狠精品视频| 亚洲欧洲一区二区三区在线观看 | 久久免费少妇高潮久久精品99| 亚洲二区视频| 国产精品99免费看 | 99精品热视频| 狂野欧美激情性xxxx| 亚洲精品免费一区二区三区| 国产精品美女久久久免费| 久久久人成影片一区二区三区观看| 亚洲精品一区二区在线| 久热精品视频在线观看| 亚洲一区二区三区欧美| 亚洲高清成人| 国产日韩欧美在线视频观看| 欧美美女喷水视频| 久久久精彩视频| 日韩视频一区二区三区在线播放| 久久久久久久性| 亚洲一区二区三区高清 | 亚洲黄色成人久久久| 国产精品午夜国产小视频| 欧美激情网友自拍| 久久精品夜色噜噜亚洲aⅴ| 一区二区高清视频| 亚洲国产精品成人va在线观看| 久久精品国产欧美激情| 亚洲视频欧美在线| 亚洲激情在线观看视频免费| 国产亚洲精品bt天堂精选| 欧美日韩亚洲综合在线| 欧美www视频| 久久先锋影音av| 欧美主播一区二区三区美女 久久精品人| 艳女tv在线观看国产一区| 亚洲第一主播视频| 久久资源av| 久久久久九九视频| 午夜亚洲视频| 亚洲专区免费| 亚洲在线视频| 亚洲视频欧美在线| 一区二区三区精品久久久| 亚洲伦理在线观看| 最新中文字幕一区二区三区| 亚洲成人在线观看视频| 韩国欧美国产1区| 久久精品欧美日韩| 亚洲小说欧美另类婷婷| 99视频一区二区三区| 亚洲精品午夜| 美女精品自拍一二三四| 亚洲一区二区不卡免费| 亚洲电影视频在线| 国产美女精品免费电影| 欧美精品亚洲二区| 久久久久国产一区二区三区| 亚洲午夜高清视频| 欧美黄色一级视频| 免费欧美日韩| 欧美激情偷拍| 亚洲区免费影片| 亚洲精品看片| 在线视频日韩| 午夜国产精品影院在线观看| 午夜精品久久久久久| 免费亚洲电影在线观看| 亚洲精品日产精品乱码不卡| 亚洲欧洲视频| 亚洲精品一区二区三区99| 亚洲欧洲日产国产综合网| 亚洲精品少妇30p| 99精品福利视频| 亚洲一区二区综合| 欧美一级电影久久| 久久婷婷人人澡人人喊人人爽| 久久野战av| 欧美激情精品久久久六区热门| 亚洲国产精品久久久久秋霞影院| 亚洲国产一区二区三区a毛片| 亚洲精品看片| 亚洲欧美制服中文字幕| 久久国产黑丝| 欧美成年人在线观看| 欧美日韩日本网| 国产欧美在线看| 亚洲国产日韩欧美在线动漫| 一本一道久久综合狠狠老精东影业| 亚洲一区二区三区视频播放| 欧美专区在线观看一区| 免费观看日韩| 日韩亚洲欧美在线观看| 亚洲欧美中文日韩在线| 久久三级视频| 欧美午夜精品理论片a级按摩| 国产亚洲成年网址在线观看| 91久久国产综合久久蜜月精品| 亚洲午夜精品网| 久久亚洲精品欧美| 亚洲美女在线国产| 欧美一区二区私人影院日本| 欧美福利视频在线| 国产伦一区二区三区色一情| 亚洲国产影院| 欧美一区视频在线| 亚洲国产经典视频| 亚洲女人天堂成人av在线| 蜜桃av噜噜一区二区三区| 国产精品久久久久久久app| 在线观看成人av电影| 亚洲综合久久久久| 欧美成人资源| 午夜精品美女久久久久av福利| 欧美顶级大胆免费视频| 国产无遮挡一区二区三区毛片日本| 亚洲精品一区二区三区在线观看| 欧美亚洲尤物久久| 欧美高清视频在线播放| 亚洲永久精品大片| 欧美精品导航| 精品动漫一区二区| 亚洲欧美综合一区| 亚洲欧洲在线播放| 久久久噜噜噜久久中文字免| 国产精品美腿一区在线看| 亚洲精品少妇| 欧美sm极限捆绑bd| 欧美一区二区精美| 欧美性大战久久久久久久| 亚洲激情啪啪| 久久久蜜桃一区二区人| 亚洲午夜高清视频| 欧美人成免费网站| 欧美私人网站| 亚洲日本aⅴ片在线观看香蕉| 久久av资源网| 亚洲一品av免费观看| 欧美区日韩区| 亚洲人体偷拍| 欧美成人影音| 久久婷婷国产综合尤物精品| 国产欧美在线播放| 欧美亚洲综合久久| 亚洲欧美日韩在线一区| 国产精品国产成人国产三级| 一区二区三区久久网| 最新国产乱人伦偷精品免费网站| 久久躁日日躁aaaaxxxx| 黄色欧美日韩| 久久亚洲国产成人| 久久精品一区二区三区不卡牛牛 | 午夜精品久久久久99热蜜桃导演| 亚洲精品自在久久| 欧美精品亚洲精品| 一本色道久久88精品综合| 亚洲国产精品视频一区| 欧美福利电影网| 99精品欧美一区二区三区| 亚洲国产精品一区| 欧美激情亚洲视频| 一区二区三区不卡视频在线观看| 亚洲人精品午夜| 欧美日韩免费在线视频| 亚洲欧美视频一区| 午夜精彩视频在线观看不卡| 国产日韩欧美高清免费| 久久精品一级爱片| 久久久999成人| 亚洲激情一区二区三区| 亚洲国产美女精品久久久久∴| 欧美福利视频在线观看| 亚洲午夜精品国产| 亚洲欧美一级二级三级| 国产亚洲视频在线观看| 免费在线成人av| 欧美黄色aa电影| 在线一区二区三区四区五区| 一区二区欧美在线| 国产欧美日韩综合精品二区| 久久人人爽国产| 免费日韩一区二区| 一本色道久久综合亚洲精品不| 一区二区三区四区精品| 国产欧美欧美| 免费亚洲电影在线| 欧美日韩日本国产亚洲在线| 欧美一站二站| 久久中文精品| 一区二区三区视频观看| 亚洲欧美综合一区|