Generic Algorithms versus Encapsulation

To explain why the STL is anti-object-oriented, we note first that object-oriented programming holds encapsulation up as an ideal. Encapsulation means bundling all your behavior in one unit. In a data structure this can mean trying to discover all the various ways that a data structure could possibly be used, and including them all as part of the interface. This can make for very fat classes, that is, for classes that have a very large interface.

The STL instead separates the data structures from the algorithms. The data structures themselves are very small. The algorithms are numerous, and can be mixed with many different data structures. This allows for a much smaller class library.

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