Take a minute right now to observe the real-world objects that are in your immediate area. For each object that you see, ask yourself two questions: "What possible states can this object be in?" and "What possible behavior can this object perform?". Make sure to write down your observations.
sun公司的java指南中在讲到“面向对象”时,用来培养面向对象概念的方法。大家可以观察现在身边的物体(对象),在观察每个物体时问自己两个问题:
1.这个物体可能处于什么样的状态?
2.这个物体大概能表现那些行为?
指南中给出了两个例子:
As you do, you'll notice that real-world objects vary in complexity; your desktop lamp may have only two possible states (on and off) and two possible behaviors (turn on, turn off), but your desktop radio might have additional states (on, off, current volume, current station) and behavior (turn on, turn off, increase volume, decrease volume, seek, scan, and tune)
You may also notice that some objects, in turn, will also contain other objects
你或许也会注意到,有些物体,in turn ,也将包含其他物体