Concepts of Object Oriented Design
-
OO design 定义:organize the software as a collection of discrete objects that incorporate both data structure and behaviour
-
object定义:可能重用的component
-
object的其他定义:a thing which has (1)behaviour, (2)state, (3)identity.
- behaviour: object的行动和响应, in terms of its state change as massage passing.
- state: 一个object当前封装的所有data. 一个object有很多attribute(也称instance variables 或者data members). Attribute的值有的是mutable,有的是immutable
- identity: object本身,不因属性值改变而改变,就好比student的age改变了,他还是他自己。the values of the object’s attributes could change, perhaps in response to a message, but it would still be the same object.
关于message的补充: Consider an object which we’ll call myClock, which understands the messages: 1. reportTime() 2.resetTimeTo(newTime) 2. A message includes a select