<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    tory320

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      10 隨筆 :: 0 文章 :: 1 評論 :: 0 Trackbacks

    Design Principle
    Identify the aspects of your application that vary and separate them from what stays the same.
    Here's another way to think about this principle: take the parts that vary and encapsulate them, so that later you can alter or extends the parts that vary without affecting those that don't.
    As simple as this concept is, it forms the basis for almost every design pattern. All patterns provide a way to let some part of a system vary independently of all other parts.

    Each set of class will hold all the implementations of their respective behavior. For instance, we might have one clss that implements quarking, another implements squaking, and another that implements silence.

    To separate thest behaviors from the Duck class, we'll pull both methods out of the duck class and create a new set of class to represent each behavior.

    This is in contrast to the way we were doing things before, where a behavior either came from a concrete implementation in the suprerclass Duck, or by providing a specialized implementation in the sub class itself. In both cases we were relying on an implementation. We were locked into using that specific implemetation and there was no room for changing out the behavior.

    And the same is true for the duck's flying behavior.

    Okay, now that we've done the deep dive on the duck simulator design, it's time to come back up for air and take a look at the big picture.

    Below is the entire reworked class structure. We have everything you'd expect: ducks extending Duck. fly behavior implementing FlyBehavior and quack behavior implementing QuackBehavior.

    Notice also that we've started to describe things a little differntly. Instead of thinking of the duck behaviors as a set of behaviors, we'll start thinking of them ad a family of algorithms. Think about it: in the SimUDuck design, the algorithms represent things a duck would do , but we could just as easily use the same techniques for a set of classes that implement the ways to compute state sales tax by different states.

    posted on 2008-03-07 17:58 tory 閱讀(136) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 性色av免费观看| 毛片免费在线观看网站| 国产乱辈通伦影片在线播放亚洲| 亚洲精品欧美综合四区| 国产一卡2卡3卡4卡无卡免费视频| 久久亚洲美女精品国产精品| 91制片厂制作传媒免费版樱花| 亚洲第一中文字幕| 51视频精品全部免费最新| 亚洲国产精品yw在线观看| 一色屋成人免费精品网站| 亚洲一区二区三区国产精品无码| 免费观看激色视频网站bd | 免费a级毛片无码a∨免费软件| 亚洲中文字幕丝袜制服一区| 妞干网免费视频观看| 亚洲熟妇AV日韩熟妇在线| 日本大片在线看黄a∨免费| 日韩精品无码永久免费网站| 免费观看激色视频网站bd| 亚洲中文字幕无码亚洲成A人片| 日本免费一本天堂在线| 一级特黄a大片免费| 国产∨亚洲V天堂无码久久久| 91香蕉国产线在线观看免费| 久久亚洲国产成人影院| 成人伊人亚洲人综合网站222| 中文永久免费观看网站| 久久久亚洲裙底偷窥综合| 天天操夜夜操免费视频| 国产黄色免费观看| 亚洲人成在线播放| 亚洲精品无码你懂的网站| 99re6免费视频| 亚洲av日韩av永久无码电影| 亚洲欧洲自拍拍偷午夜色无码| 国产免费不卡视频| 一级毛片正片免费视频手机看| 亚洲最新视频在线观看| yy6080久久亚洲精品| 在线a免费观看最新网站|