Object Programming  «Prev 

Understanding Objects and Classes

Object-Oriented Technology

Objects are key to understanding object-oriented technology. In your own life you will find many examples of real-world objects: your stuffed panda, your desk, your television set, your jet ski.
Real-world objects share two characteristics: They all have
  1. state
  2. and behavior.
Dogs have state (name, color, breed, hungry) and behavior (barking, fetching, wagging tail). Bicycles also have state (current gear, current pedal cadence, current speed) and behavior (changing gear, changing pedal cadence, applying brakes). Identifying the state and behavior for real-world objects is a great way to begin thinking in terms of object-oriented programming.
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:
  1. What possible states can this object be in? and
  2. What possible behavior can this object perform?
As you write down your observations, you will 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.
These real-world observations all translate into the world of object-oriented programming.