• <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
            數(shù)據(jù)加載中……

            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) 評(píng)論(2)  編輯 收藏 引用 所屬分類: Design pattern

            評(píng)論

            # re: Command Pattern: We used but we didn't recognize  回復(fù)  更多評(píng)論   

            沒(méi)事寮什么鳥語(yǔ)呀,rubbish!
            2009-02-22 21:14 | cindy

            # re: Command Pattern: We used but we didn't recognize  回復(fù)  更多評(píng)論   

            樓上的什么態(tài)度呀,你是看不懂吧~
            沒(méi)文化真可怕!
            2009-02-22 21:16 | Gaia
            大伊人青草狠狠久久| 精品国产乱码久久久久久郑州公司| 日韩一区二区久久久久久| 久久婷婷综合中文字幕| 欧美日韩精品久久久久| 亚洲国产美女精品久久久久∴ | 无码任你躁久久久久久久| 2021国内久久精品| 久久免费精品一区二区| 久久亚洲精品无码aⅴ大香| 日本道色综合久久影院| 99蜜桃臀久久久欧美精品网站| 精品久久久久久国产91| 思思久久精品在热线热| 国产激情久久久久影院小草| 久久精品一区二区影院| 一本久久a久久精品亚洲| 一级做a爱片久久毛片| 国产精品女同久久久久电影院 | 日产精品久久久久久久| 久久久精品国产Sm最大网站| 99久久免费国产精精品| 久久人爽人人爽人人片AV| 久久影视综合亚洲| 99久久精品免费国产大片| 国产精品女同久久久久电影院| 久久久久亚洲av成人网人人软件| 亚洲中文字幕伊人久久无码| 好久久免费视频高清| 久久久久亚洲av无码专区导航| 伊人久久成人成综合网222| 精品无码久久久久久国产| 久久99国产亚洲高清观看首页| 18岁日韩内射颜射午夜久久成人 | 久久最新精品国产| 久久久国产精品亚洲一区| 亚洲国产欧洲综合997久久| 亚洲国产美女精品久久久久∴| 伊人久久大香线蕉亚洲五月天| 久久大香萑太香蕉av| 伊人久久大香线焦AV综合影院 |