Time for another fun image statistic query. Randy Coulman shared this wonderful quote with me once, paraphrased it goes something like:
"In most languages where inheritance is singular, it's a card you only get to play once, so you'd better play it wisely"
There's this phase many go through in the "Smalltalk Exodus" where you are tempted to go nuts with abstraction. Breaking your problem down to the umpteenth layer of abstraction levels. Classification is something enjoys taking a crack at. In time, you discover the above quote be experience and you don't go quite so nuts anymore. Looking at some code in VisualWorks base image, I was inspired to inspect the following snippet:
(Object withAllSubclasses groupedBy: [:each | each allSuperclasses size) associations asSortedCollection
The deepest award goes to WinXPToolbarButtonView and WinXPSpinButtonView. Both of which have 15 superclasses between them and Object. In fact, there are a lot of look-and-feel related visual objects that have 15, 14, 13, & 12 superclasses between them and Object. In fact, in my image, they're the ONLY ones that occupy this distance from Object. The first object to show up that is of not that ilk is ExternalDictionary which has 11. And a couple of RefactoringBrowser objects occupy this tier. I think the deepest I found of our own code was at the 10 level. What's yours?
It is also kind of fun to histogram all of the classes in the image with this value. A minor twist to the above gives us the data:
((Object withAllSubclasses groupedBy: [:each | each allSuperclasses size) associations collect: [:a | a key -> a value size) asSortedCollection
In my image, I get the following (this has our code as well as a well populated development image):
Superclass Count |
Number of Classes
|
0 |
1
|
1 |
760
|
2 |
1171
|
3 |
792
|
4 |
694
|
5 |
1189
|
6 |
1403
|
7 |
883
|
8 |
716
|
9 |
452
|
10 |
253
|
11 |
99
|
12 |
30
|
13 |
28
|
14 |
24
|
15 |
11
|
16 |
2
|
Looks like 6 is the sweet spot.