• <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 攀升 閱讀(1096) 評論(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久久久香蕉| 国产99久久精品一区二区| 久久人妻AV中文字幕| 狠狠久久综合| 国产成人精品久久亚洲| 久久免费精品一区二区| 97久久天天综合色天天综合色hd| 狠狠色丁香久久婷婷综合_中 | 97久久天天综合色天天综合色hd| 亚洲天堂久久久| 四虎国产精品成人免费久久| 午夜精品久久久久| 久久亚洲精品无码AV红樱桃| 少妇内射兰兰久久| 国产综合久久久久| 国产精品VIDEOSSEX久久发布| 亚洲精品高清国产一久久| 国产综合免费精品久久久| 欧美日韩中文字幕久久久不卡| 久久露脸国产精品| 久久无码AV中文出轨人妻| 狠狠色丁香久久婷婷综合| 99久久婷婷免费国产综合精品| 久久久中文字幕| 欧美午夜A∨大片久久| 亚洲精品高清国产一线久久| 久久亚洲欧美国产精品| 国产精品丝袜久久久久久不卡| 久久综合久久伊人| 人妻无码αv中文字幕久久| 色综合久久最新中文字幕| 亚洲国产婷婷香蕉久久久久久| 三上悠亚久久精品| 久久精品免费大片国产大片| 少妇久久久久久久久久| 久久中文精品无码中文字幕| 人妻无码αv中文字幕久久琪琪布 人妻无码久久一区二区三区免费 人妻无码中文久久久久专区 | 手机看片久久高清国产日韩| 色婷婷久久综合中文久久蜜桃av| 久久99热只有频精品8|