• <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无码AV| 久久天天日天天操综合伊人av| 久久99国产一区二区三区| 久久精品国产黑森林| 亚洲国产成人久久一区久久| 久久久噜噜噜久久中文字幕色伊伊| 欧美牲交A欧牲交aⅴ久久| 亚洲一区中文字幕久久| 欧美成人免费观看久久| 国产精品久久国产精品99盘| 久久伊人色| 久久精品国产久精国产| 久久国产AVJUST麻豆| 国产成人精品免费久久久久| 久久久久九九精品影院| 久久久一本精品99久久精品88| 国产综合成人久久大片91| 久久天天躁狠狠躁夜夜2020一| 99久久精品免费| 99久久久国产精品免费无卡顿 | 亚洲欧洲精品成人久久奇米网| 浪潮AV色综合久久天堂| 欧美与黑人午夜性猛交久久久| 熟妇人妻久久中文字幕| 成人国内精品久久久久影院VR| 久久人人青草97香蕉| 国产福利电影一区二区三区久久久久成人精品综合 | 热re99久久6国产精品免费| 久久久网中文字幕| 66精品综合久久久久久久| 97久久超碰国产精品旧版| 亚洲欧美精品一区久久中文字幕| 94久久国产乱子伦精品免费| 久久99精品久久久久婷婷| 久久久精品国产免大香伊| 香蕉久久久久久狠狠色| 青青热久久国产久精品| 久久免费香蕉视频| 伊人色综合九久久天天蜜桃| 久久久久亚洲AV成人网人人软件|