• <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精品久久久久久动态图| 性高湖久久久久久久久| AAA级久久久精品无码区| 久久久久噜噜噜亚洲熟女综合| 三级韩国一区久久二区综合| 亚洲伊人久久精品影院| 国产精品久久久久一区二区三区 | 一本大道加勒比久久综合| 亚洲精品美女久久久久99小说| 久久棈精品久久久久久噜噜| 久久国产福利免费| 久久久久久午夜成人影院| 少妇被又大又粗又爽毛片久久黑人| 色狠狠久久AV五月综合| 亚洲欧洲中文日韩久久AV乱码| AV狠狠色丁香婷婷综合久久| 99久久免费国产精品特黄| 久久精品中文字幕有码| 2021精品国产综合久久| 亚洲日韩中文无码久久| 久久青青草视频| 久久青青草原精品国产不卡| 久久婷婷国产麻豆91天堂| 久久亚洲精精品中文字幕| 一本大道久久香蕉成人网| 精品久久久久中文字| 97久久精品人人澡人人爽| 99久久www免费人成精品 | 久久综合久久自在自线精品自| 亚洲欧洲久久久精品| 青青草原综合久久大伊人| 亚洲色欲久久久久综合网| 欧美日韩精品久久久免费观看| 开心久久婷婷综合中文字幕| 日批日出水久久亚洲精品tv| 欧美性猛交xxxx免费看久久久| 久久久久亚洲AV无码专区桃色| 亚洲国产精品无码久久青草 | 久久人人爽人人爽人人片AV不| 午夜欧美精品久久久久久久| 久久九九精品99国产精品|