Example - Building Sets from Lists

One way to illustrate the difference between inheritance and composition is to consider an example in the grey area in the middle, one where it is not exactly clear which technique is the correct one to use.

Suppose we already have an existing List data type, and we want to build a new Set abstraction. The essential features of a set is that elements are unique, but we have no real concern over ordering.

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