• <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 攀升 閱讀(1109) 評論(2)  編輯 收藏 引用 所屬分類: Design pattern

            評論

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

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

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

            樓上的什么態(tài)度呀,你是看不懂吧~
            沒文化真可怕!
            2009-02-22 21:16 | Gaia
            国产高潮国产高潮久久久| 国产99久久精品一区二区| 伊人伊成久久人综合网777| 亚洲午夜久久久影院| 国产成人久久精品区一区二区| 久久久青草青青亚洲国产免观| 香蕉99久久国产综合精品宅男自 | 99久久精品国产一区二区三区| 伊人久久亚洲综合影院| 日本免费久久久久久久网站| 伊人伊成久久人综合网777| 久久福利青草精品资源站| 国内精品伊人久久久久妇| 国产成人无码精品久久久免费 | 性欧美大战久久久久久久| 欧美精品久久久久久久自慰| 久久久99精品一区二区| 青青草国产精品久久| 国产成人精品久久免费动漫| 亚洲va久久久噜噜噜久久| 国产精品久久久久久久久久影院| 国产精品成人无码久久久久久| 久久久av波多野一区二区| 亚洲国产欧洲综合997久久| 国产精品一区二区久久精品涩爱| 久久久久久久综合日本| 久久电影网| 久久久久久无码国产精品中文字幕| 国产精品久久国产精品99盘| 国产精品一区二区久久| 国产亚洲美女精品久久久久狼| 久久精品无码专区免费青青 | 亚洲日本va中文字幕久久| 久久婷婷是五月综合色狠狠| 久久伊人五月丁香狠狠色| 青青草原综合久久大伊人| 亚洲中文久久精品无码ww16| 亚洲色欲久久久综合网东京热| 人妻久久久一区二区三区| 成人综合伊人五月婷久久| 久久er热视频在这里精品|