Introduction to OOP: Chapter 10: Subclasses and Subtypes [next] [previous] [audio] [real] [text]

The Container Problem

The task of reverse polymorphism is often encountered in connection with a collection of values - we have a list of items from the parent class (say a list of Mammals), and when we extract a value we need to know if it is a more specific type.

Generally occurs in languages with a single inheritance tree, where the only type we may have associated with a value is the class ``Object''.

Solving this problem generally requires values to have ``self knowledge'' of their own type. In some languages they do, in some languages values do not.

Intro OOP, Chapter 10, Slide 10

A case study examining one solution to the container class problem will be presented in Chapter 15.
Java, unfortunately, uses to term Container to mean a type of graphical component, and not a collection class, as is common in most other languages.