Navigating traits in 3.9
Andreas Raab
andreas.raab at gmx.de
Sat Oct 21 07:44:46 UTC 2006
Hi Guys -
This message feels like a deja vu to me. I think I've written something
similar in the past but it's just incomprehensible to me that I can't
figure out basic relationships in a part of the system that I know
fairly well. So here we go again:
In response to a message that talked about traits and Java interfaces I
was looking at TAccessingMethodDictDescription to find out what the
rough percentage of "provided" and "required" method is. Doing so I
stumbled across #addSelector:withMethod:notifying: and wondered by
myself where its short form of #addSelector:withMethod: went. Browsing
the senders of the former netted me 9 places to look at among which were
four implementors of #addSelector:withMethod:. And so began the tale of
the traits...
The first implementor of #addSelector:withMethod: is in Behavior which
looks like it's just a user of one of the other three and indeed
Behavior lists TPureBehavior in its traits. Looking at TPureBehavior
next, we find that it is using TCompilingBehavior which is also in the
list. Looking at TCompilingBehavior we find #addSelector:withMethod:,
but oddly enough, we also find #addSelector:withMethod:notifying: which
is the method we started from in TAccessingMethodDictDescription. So how
are these related?
Trying to find the users of TAccessingMethodDictDescription leaves us
fishing through menus with no success. "class refs" does nothing, so
does Cmd-Shift-N or any other relevant looking menu item. Switching to
OB doesn't help either. Oh well. So let's instead click through the
individual traits to find where it is used. Hm ... nothing in
Traits-Kernel-Traits. Let's try Kernel-Classes. Ah, ClassDescription
uses it! Well, if ClassDescription has it, so may TraitDescription,
let's check. Bingo!
But wait, there is something odd here. TraitDescription is a subclass of
TraitBehavior and TraitBehavior uses TPureBehavior which is composed
from TCompilingBehavior. Oh, and ClassDescription is a subclass of
Behavior which uses TPureBehavior too? Isn't that just where we
started??? Hello? You still with me? No? Didn't think so.
Seriously, there is something really wrong here. I know that part of the
system very well, and there really should be nothing particularly
complex about those methods. In previous versions of Squeak they are as
plain as it gets. I'm not sure what it is that makes it so hard to
understand the relationship but it is crazy to browse a dozen classes
and traits to find out who is responsible for delegating a trivial
method like this and why (the process does remind me fishing through
endless series of header files though, I only wish I had a Squeak
version of grep but even Cmd-Shift-E didn't help...)
Either it's poor design or it's using patterns that I don't understand.
If the latter, I'm sure a comment or two could help. Which should go
without saying but all but one of the traits in the traits kernel have
no comment whatsoever. And the one that does claims "this eliminates the
need for TraitHolders" which is great considering that we get to know
that one entity with unknown responsibilities replaces another one with
unknown responsibilities ;-)
And I'm still at square one: How exactly are these methods related? What
trait or class would I change if I'd want to change an implementation
and why? And most importantly, how would I find out by myself? What
strategies does one use to understand relationships between traits? What
tools?
Cheers,
- Andreas
More information about the Squeak-dev
mailing list
|