The difference between the OO and object-based approaches is that the OO approach adds the concept of inheritance to mimic the way people normally think when they classify objects. Inheritance permits new types (also called classes) to be defined as extensions of other existing types, forming a hierarchy of type definitions. Inheritance represents the relation ``is a kind of'' (as opposed to the relation ``is a part of'' or some other relation). To continue our example, we could create two new types called ``motorcycle'' and ``bus'' as kinds of vehicles. Thus bus and motorcycle would inherit from vehicle. Note that a type called ``wheel'' should generally not inherit from type vehicle; a wheel is a part of a vehicle, but a wheel (by itself) is not a vehicle.
A type inherits all of the data structure and operations, so in our example a bus would also have a drive_to(location) operation. More importantly, once we create a new type, we can create additional operations that only apply to it, or redefine existing operations to perform special actions for this type. For example, we could add operations to a bus to allow it to accept_passengers, and this new operation would apply to buses, not to motorcycles or to all vehicles. We could also redefine the ``drive_to(location)'' operation of a bus so it would do something different with buses.
OO programming is an approach to implementing software using the OO approach. Grady Booch [1994] defined OO programming this way: ``OO programming is a method of implementation in which programs are organized as cooperative collections of objects, each of which represents an instance of some class, and whose classes are all members of a hierarchy of classes united via inheritance relationships.''
It is difficult to use OO and object-based techniques if the underlying programming language does not support certain capabilities well. In particular, OO techniques are difficult to use if the programming language used does not directly support inheritance (and a related concept called polymorphism or dynamic dispatching, which will be explained later). Ada was explicitly designed from the beginning to support an object-based approach, and in 1995 Ada was extended to support OO programming.
The definition of ``functional decomposition'' given above is the usual approach when it is implemented in Fortran and Pascal, though again, definitions are not universally agreed upon. In particular, do not confuse this with ``functional programming languages'', which support an approach that is a very different extension of functional decomposition. There are other system decomposition approaches, such as logical programming, that are way beyond the scope of this tutorial. It can be argued that abstract data types and object-based approaches aren't identical; such arguments generally hinge on detailed definitions which have never had universal agreement.
Here are simplified descriptions of two different systems. Which one is described in a more OO manner?
System 1 is an anti-missile system with 3 major types of components: a radar, a launcher, and a missile. A radar searches the portion of the sky defined by its area_of_search information. When a radar sees a target it sends a `target sighting' message to a launcher. When a launcher receives a `target sighting' message and that launcher's combat_state is `armed', it selects a missile to launch and sends that missile a launch command. A missile accepts a `launch command', which includes the launch time and the expected target location; it will then launch at the given time. There are two kinds of missiles, a long_range_missile and a short_range_missile.
System 2 is a coin-operated soup dispenser. It accepts coins, then accepts a user's soup choice, and then dispenses soup. To accept coins it counts each coin's value until the total equals or exceeds the cost of a cup of soup. To accept a user's soup choice, the system waits for a selection button to be pressed. To dispense soup, it drops a cup into the user-accessible cup holder, dispenses the selected powdered soup into the cup, dispenses boiling water into the cup, and then stirs the soup. To stir the soup, a plastic stirrer is inserted into the cup, the stirrer is vigorously moved about inside the cup, and the stirrer is then removed.
Which system has been described in a more object-oriented manner?
![]() |
![]() |
![]() |
---|
David A. Wheeler (dwheeler@ida.org)