• <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 攀升 閱讀(1109) 評論(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
            久久精品免费大片国产大片| 色综合久久久久久久久五月| 久久精品国产精品亚洲毛片| 国产亚洲婷婷香蕉久久精品| 久久综合九色综合97_久久久| 久久中文精品无码中文字幕 | 欧美激情精品久久久久久久九九九 | 欧美久久一级内射wwwwww.| 亚洲国产天堂久久综合| 久久91综合国产91久久精品| 亚洲性久久久影院| 久久综合狠狠色综合伊人| 亚洲中文字幕无码久久2020| 国产精品成人99久久久久 | 色偷偷91久久综合噜噜噜噜| 99久久久精品| 久久精品中文无码资源站| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 亚洲级αV无码毛片久久精品| 国内精品久久久久久不卡影院| 亚洲日韩中文无码久久| 久久久久亚洲精品中文字幕| 久久精品国产99国产精偷| 麻豆精品久久久久久久99蜜桃| 国产综合精品久久亚洲| 日韩精品国产自在久久现线拍| 无码人妻久久久一区二区三区| 国产偷久久久精品专区| 久久久久久久综合狠狠综合| 久久成人18免费网站| 久久精品三级视频| 久久久久亚洲AV无码专区网站 | 亚洲美日韩Av中文字幕无码久久久妻妇| 国产成人久久精品区一区二区| 久久久精品人妻一区二区三区蜜桃 | av午夜福利一片免费看久久| 久久久一本精品99久久精品66| 久久久久无码精品国产不卡| 久久国产亚洲高清观看| 久久精品一区二区国产| 久久精品国产91久久麻豆自制|