3.4 面向对象分析(一)面向对象设计(初步)

一般原则

   An object-oriented system is composed of objects sending messages to other objects

   The quality of the overall design depends on which object is doing what

     比喻:“人尽其责、各有所长”

   That is, the quality depends on how we assign responsibilities to the objects

   Problem:

     Define “good quality”?
职责驱动的设计 (RDD)

   RDD,Responsibility Driven Design

     Pioneered by Wirfs-Brock in early 90s

     Think of objects in terms of what they do or know (the human worker metaphor!)

      设计时考虑对象做什么、或者知道什么
     An object’s obligation or contract that it offers to other objects

      一个对象对其他对象承担的义务或者合约

     A responsibility is really a behavior the other classes depend on

      职责是一个对象的行为,而其他的对象依赖这种行为 
职责的定义 Responsibilities

   这里定义为两类Knowing、Doing
   认知职责 Knowing

     about private encapsulated data

     about related objects

     about things it can derive or calculate
   行为职责 Doing

     doing something itself

     initiating action in other objects

     controlling and coordinating activities in other objects

posted @ 2019-03-15 14:13  otr  阅读(306)  评论(1编辑  收藏  举报