Strong Typing versus Containers

One would think that if any software abstractions were candidates for development as reusable abstractions it would be the classic container classes studied in data structures courses. But things are not as easy as they might seem. There is a serious conflict between the goals of strong typing, and the goals of developing reusable abstractions.

To be reusable, a container class abstraction must be independent of the current application. This means that the programmer creating a reusable container class will have no idea what type of object it will hold. But when I place a value into a container, I hope to get the same value back when I remove it from the container.

We therefore have a conflict. Does or does not the container know what type of value it is holding?

[audio] [real] Text to accompany slide2, in Chapter 15 of An Introduction to Object-Oriented Programming