Sorry about the long delay between articles, I was busy getting married. A big thank you to the people who asked if I was going to write any more: I’m back in the game now.

When I built Animator.js, I got some flack for suggesting that inheritance is not a Good Thing. Keen to avoid a holy war I restated my position to ‘inheritance is often useful, but more often overused.’ Over the last few months I’ve been trying to figure out exactly when it should be used, and have concluded - at least for the kind of systems GUI developers build - never. There are better techniques that accomplish the same thing.

In this article I justify my dislike of inheritance as a prelude to my next article introducing an open source animation toolkit that is built without inheritance.

Read the article here.

Edit: Eric Herman wrote in with a link to a good article he wrote giving a more detailed example of the same problem from a Java point of view.

Edit 2: OK, I couldn’t make this stuff up. This is a verbatim quote from the Java API documentation for the Properties class that reads configuration from a file:

Because Properties inherits from Hashtable, the put and putAll methods can be applied to a Properties object. Their use is strongly discouraged as they allow the caller to insert entries whose keys or values are not Strings. The setProperty method should be used instead. If the store or save method is called on a “compromised” Properties object that contains a non-String key or value, the call will fail.

This is what inheritance does to your system! In all fairness, the Java API team introduced the generic collections API to get around this kind of problem, but it’s still funny.