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

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 常興龍 閱讀(1029) 評(píng)論(4)  編輯 收藏 引用 所屬分類(lèi): 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>
            久久精品国产一区二区电影| 久久综合色综合88| 国产精品日韩精品欧美在线| 欧美高清在线视频观看不卡| 久久久亚洲精品一区二区三区 | 国产精品久久午夜夜伦鲁鲁| 欧美日韩小视频| 国产精品二区三区四区| 国产欧美一区二区三区久久| 国产亚洲综合精品| 亚洲片国产一区一级在线观看| 亚洲精品综合久久中文字幕| 亚洲综合精品自拍| 久久久亚洲欧洲日产国码αv | 国内伊人久久久久久网站视频| 在线视频成人| 亚洲免费综合| 模特精品在线| 一本色道久久综合狠狠躁篇怎么玩 | 久久久久青草大香线综合精品| 可以看av的网站久久看| 亚洲欧洲一区二区三区久久| 蜜臀av一级做a爰片久久| 亚洲国产欧美另类丝袜| 午夜在线电影亚洲一区| 欧美精品一区二区三区四区| 国产视频久久久久| 一区二区激情视频| 久久综合电影| 亚洲天堂成人| 欧美精品一区视频| 在线看视频不卡| 午夜在线不卡| 亚洲伦理在线| 美国三级日本三级久久99| 国产精品亚洲欧美| 99天天综合性| 欧美大片在线看| 欧美与黑人午夜性猛交久久久| 欧美麻豆久久久久久中文| 亚洲欧美日韩电影| 欧美成在线视频| 红桃av永久久久| 午夜一级久久| 99天天综合性| 欧美日韩黄色一区二区| 亚洲二区在线| 老司机精品久久| 香蕉av777xxx色综合一区| 欧美吻胸吃奶大尺度电影| 亚洲激情在线观看视频免费| 久久亚裔精品欧美| 羞羞视频在线观看欧美| 国产精品免费福利| 亚洲一区区二区| 99精品免费| 欧美视频在线播放| 亚洲丝袜av一区| 日韩特黄影片| 欧美亚一区二区| 亚洲免费在线看| 亚洲欧美日韩视频二区| 国产精品一区三区| 欧美一区视频| 欧美在线日韩精品| 在线观看国产精品淫| 美女图片一区二区| 免费在线成人| 99国产精品久久| 99国产精品视频免费观看一公开| 欧美日本久久| 中文日韩电影网站| 亚洲永久字幕| 国内精品久久久久影院薰衣草| 久久久999精品免费| 久久久久久91香蕉国产| 亚洲国产精品成人va在线观看| 欧美成人首页| 欧美日韩hd| 欧美在线关看| 美女999久久久精品视频| 99精品国产福利在线观看免费| 亚洲九九九在线观看| 国产精品美女在线观看| 久久精品国产欧美激情| 久久野战av| 亚洲桃色在线一区| 欧美在线三区| 亚洲免费高清| 午夜精品久久久久久久| …久久精品99久久香蕉国产| 91久久在线视频| 国产精品影音先锋| 欧美激情一区二区三级高清视频| 欧美日韩精品中文字幕| 久久久久国产一区二区| 欧美精品日韩一本| 久久久99爱| 欧美体内she精视频| 免费欧美在线| 国产精品久久久久久久久借妻| 欧美r片在线| 国产精品欧美激情| 亚洲视屏在线播放| 欧美一区二区三区免费在线看| 日韩视频亚洲视频| 午夜精品一区二区三区在线| 亚洲日本一区二区三区| 午夜欧美精品| 一区二区三欧美| 久久九九热免费视频| 亚洲一区二区三区四区在线观看| 久久精品国产99国产精品| 亚洲网在线观看| 欧美v国产在线一区二区三区| 性欧美办公室18xxxxhd| 欧美精品国产精品日韩精品| 另类天堂视频在线观看| 国产精品主播| 亚洲视频网在线直播| 亚洲理论在线| 老色批av在线精品| 久久先锋资源| 国产视频一区二区三区在线观看| 99www免费人成精品| 亚洲精品久久7777| 美日韩精品免费| 蘑菇福利视频一区播放| 黄色av日韩| 久久精品亚洲| 久久久97精品| 国产一区二区三区奇米久涩| 亚洲免费影视| 久久不射中文字幕| 国产欧美日韩激情| 亚洲影视中文字幕| 欧美一区二区三区婷婷月色 | 午夜国产精品视频| 欧美久色视频| 亚洲免费av片| 亚洲美女网站| 欧美日韩国产经典色站一区二区三区| 亚洲国产精品美女| 亚洲精品乱码久久久久久蜜桃麻豆| 玖玖在线精品| 亚洲国产精品久久久久秋霞不卡| 91久久在线观看| 欧美日韩免费观看一区三区| av成人免费| 亚洲欧美三级在线| 国产日韩三区| 久久精品理论片| 欧美黄色网络| 这里只有精品在线播放| 国产精品豆花视频| 久久av资源网站| 亚洲国产乱码最新视频| 洋洋av久久久久久久一区| 欧美亚洲成人免费| 欧美一区二区三区日韩| 免费观看成人| 一本色道久久综合亚洲91| 欧美性一区二区| 午夜视频久久久| 欧美激情小视频| 99国内精品| 久久久一区二区| 欧美成人一品| 亚洲一区二区三区中文字幕| 国产亚洲欧美中文| 欧美成人免费大片| 亚洲午夜久久久久久久久电影院| 久久国产精品久久久久久久久久 | 亚洲激情国产精品| 国产精品国产三级国产专播精品人 | 亚洲美女啪啪| 欧美中文在线免费| 亚洲精品免费电影| 国产欧美一区二区三区国产幕精品| 久久久久久久国产| 一本色道久久88综合日韩精品| 久久久www| 在线综合+亚洲+欧美中文字幕| 国产在线拍偷自揄拍精品| 欧美黄免费看| 久久婷婷蜜乳一本欲蜜臀| 一本大道久久a久久精二百| 麻豆成人精品| 久久爱另类一区二区小说| 一本大道久久a久久精二百| 国产综合一区二区| 国产精品久久99| 欧美人妖另类| 欧美国产高清| 免费91麻豆精品国产自产在线观看| 亚洲一区二区三区午夜| 亚洲激情视频在线| 老牛嫩草一区二区三区日本| 午夜精品久久久久久久| 中国成人亚色综合网站|