<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 閱讀(137) 評論(0)  編輯  收藏

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


    網站導航:
     
    主站蜘蛛池模板: 99久久精品国产免费| 亚洲最大的成人网| 精品无码国产污污污免费网站国产| 在线不卡免费视频| 亚洲爆乳少妇无码激情| 国产免费无遮挡精品视频| 黄色毛片视频免费| 亚洲国产综合精品一区在线播放| 成人福利在线观看免费视频| 一本色道久久综合亚洲精品高清| 中国一级全黄的免费观看| 久久精品国产亚洲综合色| 久久久久高潮毛片免费全部播放| 久久久久久久亚洲Av无码| 狼群影院在线观看免费观看直播| 33333在线亚洲| 免费一级毛片在线观看| 亚洲天堂免费在线视频| 亚洲国产精品无码久久久秋霞2 | av大片在线无码免费| 亚洲三级在线免费观看| 国产精品无码素人福利免费| 人成免费在线视频| 亚洲综合自拍成人| 最近免费中文字幕大全| 一区二区3区免费视频| 亚洲三级电影网址| 国产麻豆免费观看91| 久久久久久久久久免免费精品| 亚洲第一精品福利| 成人网站免费观看| 国产精品1024在线永久免费 | 中文字幕乱码亚洲无线三区| 免费人成在线观看网站视频| a级片免费在线观看| ASS亚洲熟妇毛茸茸PICS| 亚洲精品无码日韩国产不卡?V| 99精品视频在线观看免费播放| 亚洲精品天堂成人片AV在线播放| 亚洲香蕉成人AV网站在线观看| 7723日本高清完整版免费|