03 Apr 2012 [ 201 week12 ]

We'll go over the interfaces and classes in the Java Collections Framework, making use of this example.

Here is where we'll start to see a lot of examples of Jon Postel's principle:

Be liberal in what you accept, and conservative in what you send.

In Java terms, that means your arguments and return values should be the simplest reasonable choice among interfaces available. For example, don't promise to return an ArrayList when a List will do; or if your sum routine works with any Iterable, don't require an ArrayList as input.

Postel, a key figure in the development of the Internet, may have been speaking concretely about network protocols, but the idea is a key design principle of Unix, and the idea is one of the best ways to improve encapsulation.

We'll also encounter some of the I/O hierarchy and some of the Exception hierarchy.