• <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
            狠狠色丁香久久综合五月| 久久国产精品一区| 久久香蕉超碰97国产精品| 久久免费的精品国产V∧| 97久久综合精品久久久综合| 久久久久免费精品国产| 蜜臀久久99精品久久久久久| 久久精品人妻中文系列| av国内精品久久久久影院| 国产精品久久久久乳精品爆| 99久久国产宗和精品1上映| 国内精品久久久久影院日本| 久久强奷乱码老熟女| 久久免费的精品国产V∧| 久久久综合香蕉尹人综合网| 伊人久久大香线焦AV综合影院| 久久国产香蕉视频| 久久99精品久久久久久动态图 | 国产免费久久精品99re丫y| 99久久久精品免费观看国产| 欧美日韩精品久久久久| 久久久久久国产a免费观看不卡| 无码人妻久久一区二区三区| 人妻无码久久精品| 亚洲天堂久久精品| 久久天堂电影网| 波多野结衣中文字幕久久| 狠狠色丁香久久婷婷综合| 久久亚洲天堂| 日韩中文久久| 久久久久九国产精品| 久久本道综合久久伊人| Xx性欧美肥妇精品久久久久久| 99精品久久精品| 91精品国产综合久久久久久| 亚洲av伊人久久综合密臀性色| 久久人人爽人人爽人人片av麻烦| 色综合久久夜色精品国产| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 久久久久久久波多野结衣高潮| 亚洲精品无码久久久|