howard.stearns at qwaq.com
Fri Jun 29 16:14:08 UTC 2007
It may seem like there are arguments on on both sides as to where
something should "live", and that there is no right answer. But I think
there is actually a way to tell if an architectural question has been
The cost of making a change ought to be proportional to the size of
the problem, not proportional to the size of the code base.
Thus it is "bad" architecture to have methods on a "namespace" object if
(and only if) doing so violates the golden rule.
That might be the case if I have to sort though a lot of crap to tell
whether adding or even using something will work. While it is true that
adding anything to a "namespace" object increases the amount of stuff to
sort though, adding methods does not UNIQUELY do so. Every entry to a
SystemDictionary increases the volume in the same way as adding a method.
Another issue is the possibility of conflict. I.e., the name has already
been used for some other purpose. Again, the issue is true for methods
and for dictionary elements separately, but identically.
I think much of the potential problems are really tools issues. For
example, I don't have to worry about learning all the methods if the
tools show me elements from orthogonal contexts in separate groups.
(Namespace/conflict resolution by context is a little more fundamental.)
I can imagine someone thinking -- "This is all well and good, but the
tools are what they are. With the ones we have, I am encouraged to think
of methods on a class as being part of that class, and having more
stuff on the class makes it too hard to learn, analyze, and decompose
for different purposes or deliverables." I think this is actually quite
true, but it is not uniquely so for the question at hand -- methods on
the Smalltalk object. For example, it is also true for Piers Cawley's
idea to add a method to everything that behaves like a collection. With
the tools and the language as they are, Piers has more work ahead of him
than he should have to in order to create and distribute such an
extension and to know that it will be right. But in the
SmalltalkDictionary methods case, I just don't see any overt violation
of the Golden Rule - even with current tools.
One of the things that excites me about Alan et al's new project is that
it seems to me to be dealing with this fairly head on.
More information about the Squeak-dev