• <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
            久久久久高潮毛片免费全部播放| 精品免费久久久久久久| 久久无码一区二区三区少妇| 久久精品中文字幕大胸| 久久综合九色综合网站| 国产成人精品久久亚洲| 久久只有这精品99| 精品久久久久久亚洲| 国产福利电影一区二区三区久久老子无码午夜伦不 | 亚洲国产精品久久久久婷婷软件| 久久午夜电影网| 久久婷婷五月综合成人D啪 | 久久国产三级无码一区二区| 久久精品国产2020| 精品国产综合区久久久久久| 亚洲精品无码久久久久sm| 精品久久人人做人人爽综合| 亚洲国产欧美国产综合久久| 久久久久亚洲精品男人的天堂| www.久久热.com| 日韩av无码久久精品免费| 久久影视综合亚洲| 久久久精品国产亚洲成人满18免费网站 | 久久无码中文字幕东京热| 久久国产精品久久久| 无码伊人66久久大杳蕉网站谷歌 | 一级女性全黄久久生活片免费 | 久久综合九色综合久99| 久久亚洲国产午夜精品理论片| 久久天天躁狠狠躁夜夜躁2014| 色欲综合久久躁天天躁| 久久99精品久久久久久水蜜桃| 久久精品国产福利国产秒| 久久精品免费一区二区三区| 国产69精品久久久久777| 国产精品久久久久9999| 狠狠色丁香婷综合久久| 91精品国产91久久久久久| 日本免费久久久久久久网站| 狠狠色丁香久久婷婷综| 国产成人久久精品麻豆一区 |