• <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 攀升 閱讀(1101) 評論(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
            日日狠狠久久偷偷色综合96蜜桃| 99久久精品免费看国产一区二区三区 | 精品无码久久久久久午夜| 亚洲αv久久久噜噜噜噜噜| 亚洲精品乱码久久久久久按摩 | 日本久久久久亚洲中字幕| 99久久超碰中文字幕伊人| 久久久久99精品成人片牛牛影视 | 久久男人Av资源网站无码软件| 国产精品视频久久| 亚洲精品乱码久久久久久不卡| 亚洲香蕉网久久综合影视 | 日韩精品久久久久久| 久久久国产亚洲精品| 国内精品伊人久久久久| 伊人久久国产免费观看视频| 97精品伊人久久大香线蕉app| 久久www免费人成精品香蕉| 国内精品久久久久伊人av| 久久久久亚洲精品中文字幕| 97久久精品人妻人人搡人人玩| 亚洲国产日韩欧美久久| 777久久精品一区二区三区无码| 久久综合视频网| 性欧美大战久久久久久久| 伊人色综合久久天天| 国产精品久久久久久搜索| 亚洲AV日韩AV天堂久久| 一本一本久久aa综合精品| 四虎久久影院| 久久综合成人网| 久久精品国产第一区二区| 91精品国产91久久久久久青草 | 久久亚洲sm情趣捆绑调教| 日韩va亚洲va欧美va久久| 久久WWW免费人成—看片| 91精品观看91久久久久久| 中文字幕亚洲综合久久2| 久久精品国产只有精品2020| 久久99精品久久久久久hb无码| 无码伊人66久久大杳蕉网站谷歌|