• <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
            情人伊人久久综合亚洲| 久久99精品久久久久久噜噜| 亚洲国产精品无码久久青草| 亚洲国产成人精品91久久久| 欧美国产精品久久高清| 无码任你躁久久久久久老妇App| 97久久国产综合精品女不卡| 99久久精品免费看国产免费| 久久久无码精品亚洲日韩蜜臀浪潮 | 国产成人久久精品一区二区三区| 久久亚洲国产精品五月天婷| 精品国产乱码久久久久久1区2区| 青青青国产精品国产精品久久久久| 天天综合久久一二三区| 国产福利电影一区二区三区久久久久成人精品综合 | 一本大道久久香蕉成人网| 久久久精品免费国产四虎| 日日噜噜夜夜狠狠久久丁香五月| 热久久国产欧美一区二区精品| 久久久久女人精品毛片| 亚洲综合熟女久久久30p| 久久偷看各类wc女厕嘘嘘| 99精品国产在热久久无毒不卡| 久久天天躁夜夜躁狠狠| 亚洲国产精品高清久久久| 亚洲精品无码久久久久sm| 久久久久亚洲av无码专区喷水 | 久久亚洲精精品中文字幕| 99久久精品免费国产大片| 一本久久a久久精品综合香蕉| 久久精品国产亚洲av麻豆图片 | 综合网日日天干夜夜久久| 久久精品国产99国产精偷| 香港aa三级久久三级老师2021国产三级精品三级在 | 久久亚洲熟女cc98cm| 91精品国产高清久久久久久io| 久久无码AV中文出轨人妻| 日本精品久久久久中文字幕8| 久久综合一区二区无码| 91视频国产91久久久| 精品综合久久久久久888蜜芽|