Re: Inheritance Considered Harmful Bill Frantz (frantz@communities.com)
Fri, 23 Oct 1998 10:49:15 -0700

OK, we are all agreed about the value of Inheritance. Now who's going to write the paper, and where are we going to try to get it published.

The main points I see are:

GUI toolkits seem to make heavy use of inheritance. We should probably think of what a no-inheritance GUI would look like.

On the other hand, it is quite useful in Java to know that every object has a toString() method. (And somewhat bogus to know that it also has wait() and notify() methods.) The equals(Obj foo) and hashCode() methods are also somewhat questionable. The getClass(), and finalize() methods are somewhat Java specific, one being a not bad idea, and the other one being poorly thought out at best.

The clone() method is weird. It is defined to throw an exception unless the class implements the Cloneable interface. It sounds like a hack to give programmer control over access to a native method.

On the other hand, yesterday I worked around a bug in Java's PipedInputStream by subclassing. The workaround allows us to ship a working program within our "ship only unmodified Java" license.