[self-interest] self-ish factoring
Jecel Assumpcao Jr
jecel at merlintec.com
Mon Jan 8 20:44:38 UTC 2001
Kyle,
for the 37380 methods in the Demo snapshot, we have this distribution
of source length (31886, or 85%, are less than 1000 bytes long):
0-99 10776
100-199 4778
200-299 3791
300-399 4110
400-499 2780
500-599 1773
600-699 1212
700-799 1063
800-899 887
900-1000 716
1000-1999 4173
2000-2999 593
3000-3999 407
4000-4999 99
5000-5999 28
10500 1
219700 193
Repeating the same thing but counting in number of lines we have
(20085, 53%, are less then 10 lines long):
1 5615
2 2101
3 2721
4 2630
5 1728
6 1582
7 1391
8 1323
9 994
10-19 10441
20-29 3274
30-39 1860
40-49 622
50-59 259
60-69 268
70-79 128
80-89 131
90-99 91
100-109 25
120-129 2
238 1
3449 193
The 238 line method is one that creates a frameMorph full of little
icons, all "spelled out" in details. The 193 very large methods seem to
be code to recreate objects for the tutorial.
When browsing with an outliner, you can directly see the code for all
methods which are just one line long when they, plus the method name,
are short enough to fit in the outliner's width. My impression is that
from one fourth to one half of the methods I see are in that group,
which seems to agree with the numbers above.
I have written some very large methods in Self, unfortunately. These
were either due to a lack of experience or the need to do complex
object initializations. So I would expect future Self programs to be
nearly as well factored as Forth programs. Note that it was easier to
deal with longer methods in the old, text based Selfs but with shorter
methods (you don't have to open them) in Self 4.
Forth has an advantage - there is little overhead for defining words
and none at all for using them. But Self has objects, not just words.
And this is a very, very important point: a truly object oriented
program has most of its "smarts" in the way the objects are connected
to each other, not inside each object. This makes them hard to
understand by reading the code - the methods are so short and mostly
seem to be delegating the same messages to other objects instead of
actually doing anything.
The other day I was trying to explain this to a person and comparing
objects with neural networks. People coming from a procedural language
tend to create one giant object with a few, large methods and several
dumb objects (nothing but data slots).
-- Jecel
More information about the Self-interest
mailing list