<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

    2008年3月7日 #

    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 @ 2008-03-07 17:58 tory 閱讀(136) | 評論 (0)編輯 收藏

    主站蜘蛛池模板: 亚洲最大av无码网址| 国产午夜免费福利红片| 亚洲理论电影在线观看| 人禽伦免费交视频播放| 亚洲国产aⅴ综合网| 特黄特色的大片观看免费视频| 免费在线观看理论片| 一级毛片aa高清免费观看| 亚洲AV无码乱码精品国产| 视频免费1区二区三区| 精品亚洲成α人无码成α在线观看| sss日本免费完整版在线观看| 4338×亚洲全国最大色成网站| 中文字幕乱码系列免费| 婷婷久久久亚洲欧洲日产国码AV| 美女被cao网站免费看在线看| 亚洲无线电影官网| 毛片免费观看的视频在线| 美女被艹免费视频| 亚洲国产另类久久久精品黑人| 久久精品无码专区免费东京热| 中文字幕乱码亚洲精品一区| 国产在线19禁免费观看| 一级特黄录像免费播放肥| 亚洲精品视频专区| 国产三级免费电影| 99久久国产精品免费一区二区| 亚洲视频一区在线| 国产乱人免费视频| 两个人www免费高清视频| 亚洲欧洲在线播放| 四虎永久成人免费影院域名| 国产免费福利体检区久久| 亚洲乱码中文论理电影| 免费国产真实迷j在线观看| 麻豆精品成人免费国产片| 国产精品亚洲综合久久| 亚洲熟妇中文字幕五十中出| 久久精品国产免费观看三人同眠| 国内成人精品亚洲日本语音| 久久久久亚洲AV无码专区首|