Clojure is about programming to abstractions
Saturday, November 8, 2008
I came across a nice
inheritance graph for Clojure in the files section of the
Clojure Google Group. It was created by
Chouser and the source
code for generating it is
here (on my Mac, I just had to tweak the paths in the "srcpath"
and "png" defs). Very nice way to visualize the relationships:

As Rich
Hickey
said:
"Clojure is about programming to abstractions, among other things. So you don't want to rely on the exact concrete types of things, but rather the interfaces they implement.
There are many useful interfaces in Clojure. Chouser put together a nice visualization:
http://clojure.googlegroups.com/web/chart.png
If you use class as a dispatch function in a multimethod, you can use an interface, like IPersistentMap, as a dispatch value and it willmatch all classes that extend IPersistentMap, since multimethod dispatch uses isa?
There are also predicates that correspond to most of the interfaces, like map?, list?, vector?, sorted? etc, all of which internally use (instance? someInterface x). The aforementioned chart includes the corresponding predicates.
In general, it is bad style to use class equality, as in (= (class this) (class that)) - better to use instance? or isa?. "

