• <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>

            攀升·Uranus


            Something Different,Something New
            數據加載中……

            Command Pattern: We used but we didn't recognize


                    Class A wanna class B do what he want to (command). Simple way, invoke B's method, that's a good idea, but don't follow the OO principle: decouple

            How to do it?  

                    Firstly, B is a stable class; he can in charge of all his responsibility. Maybe there are too many classes like B that A wants to invoke. So how to do it, A composition or aggregation all classes that he needs? Of course not, too much dependence with A. So let’s think about this with OO principle: Encapsulate What Varies.
             

                   There are many unpredictable commands that are the variety in this case. We need to encapsulate the command and plugin to A. So at that time, A just knows he is invoking a command, and doesn’t know who and how to execute that command.

                   Secondly, how to plugin to A. I don’t wanna talk about DI or Java mechanism. I am handling C++, so just add a method named SetCommand(Command* pCommand) to A, that's fine.

                   Lastly, I showed a UML figure 1-1 that described all the means.

                 

                                                                            Figure 1-1 
                   
            Everybody’ll shout: that is command pattern.  Yes.

                    As the title said: we used but we didn't recognize. So let’s start with its official definition:

                    The Command Pattern encapsulate a request as an object, thereby letting you parameterize other objects with different request, queue or log requests, and support undoable operations.

            posted on 2009-02-20 21:00 攀升 閱讀(1096) 評論(2)  編輯 收藏 引用 所屬分類: Design pattern

            評論

            # re: Command Pattern: We used but we didn't recognize  回復  更多評論   

            沒事寮什么鳥語呀,rubbish!
            2009-02-22 21:14 | cindy

            # re: Command Pattern: We used but we didn't recognize  回復  更多評論   

            樓上的什么態度呀,你是看不懂吧~
            沒文化真可怕!
            2009-02-22 21:16 | Gaia
            亚洲国产成人久久综合碰| 人妻精品久久久久中文字幕一冢本| 国产精品亚洲综合久久| 少妇久久久久久被弄到高潮| 亚洲精品无码久久毛片| 99久久国产亚洲综合精品| 亚洲AV日韩AV永久无码久久 | 久久久久久综合一区中文字幕 | 99久久免费国产精精品| 国内精品久久久久久中文字幕| 亚洲欧美久久久久9999| 久久综合给久久狠狠97色| 久久久久香蕉视频| 大美女久久久久久j久久| 久久夜色精品国产亚洲| 午夜精品久久久久久影视riav | 久久久久久久免费视频| 久久国产精品99久久久久久老狼 | 久久婷婷五月综合97色直播| 国产午夜福利精品久久2021| 青草国产精品久久久久久| 久久久久久亚洲精品不卡| 日本精品久久久中文字幕| 狠狠色婷婷久久综合频道日韩| 香蕉久久夜色精品国产尤物| 亚洲天堂久久精品| 一本一道久久精品综合| 欧美精品乱码99久久蜜桃| 久久精品亚洲精品国产欧美| 麻豆精品久久精品色综合| 99久久综合狠狠综合久久止| 7777久久久国产精品消防器材| 亚洲另类欧美综合久久图片区| 久久精品人人做人人爽电影| 99国产精品久久| 激情伊人五月天久久综合| 国产成人精品白浆久久69| 久久久精品2019免费观看| 91久久精品国产91性色也| 久久亚洲高清观看| 精品久久久久久久久久中文字幕 |