Polymorphism / Late-Binding
Polymorphism and late-binding are concepts designed to make computer objects a little like real-world objects, by ensuring that using common behavior doesn't require an in-depth knowledge of the object. An example from the real world is picking up and throwing things. Most small things, like pebbles, sticks, fruit, books, eggs and shoes can all be picked up and thrown, and you don't need to know too much about them in order to get them to sail through the air. You certainly don't need to know how many pips the fruit has, or whether the shoelaces on the shoes are nicely done up. You may have to modify your behavior a bit for some less common throwable objects, like houses, cats and loved ones but the principle is there Â the details don't matter too much.
For strongly typed languages such as C++ and Java, acquiring this kind of "don't care" behavior is not trivial because the nature of all available objects is supposed to be strictly and completely known at all times. For those languages, the problem is solved with the technique of late-binding which, very roughly speaking, defers the "need to know everything" requirement until a given program is actually running. Such languages normally need to know everything at compile (preparation) time.
Association is not a core requirement for object-orientedness in a language, but it is used so much in object-oriented design that it's worth covering for completeness. Association is a powerful concept because it is the only way that objects can have access to each other without the "sole ownership" implications of containment as discussed above.
In this example, many Traveller objects might use the same Mini object as their preferred transport. Hopefully checks will always be done so that sharing the object makes sense. In this case that means that no more than four Traveller objects should share the Mini object. When a Traveller object is finished with the Mini object, then this code might be used:
When this happens, the Mini object won't cease to exist, as the car variable will always point to it. But one less person will associate the Mini object with themselves.
Created: February 5, 2001
Revised: February 5, 2001