[squeak-dev] <Method Tags> (Pragmas)

Ralph Johnson johnson at cs.uiuc.edu
Sun May 2 09:30:28 UTC 2010


I didn't understand Hernan's response.  It complained about tags but didn't
give any alternatives, and because I couldn't see any alternatives I had no
idea what the complaints were about.  But Colin's message is much more
concrete and provides an easy to understand alternative.

If tags are a way of categorizing methods so that other tools can find them,
an alternative is to find them based on their name.  The SUnit testrunner
will automatically run methods whose name starts with "test" if they are in
subclasses of TestCase.  When I studied OmniBrowser a year or two ago, I
found the way commands were defined to be pretty easy.  The main thing
making them hard to learn was lack of up-to-date documentation (class
comments would be nice!) but commands were one of the easier things to
figure out.

Another alternative is to rind them based on the protocol they are in.
SUnit tests are almost always in a protocol called "Testing".  The
TestRunner could have used that instead.  The main problem with this is that
Monticello uses protocols to specify packaging, though I think that was a
bad design decision.

i don't see why method tags are so bad.  They will become part of the
standard reflective definition of methods.  You'll be able to ask a class
for all its methods with a particular tag, and you can easily get a
collection of all methods in the system with a particular tag by iterating
over the classes.  To me, this is no different than asking a class for
methods whose name starts with "test".  Tags are better than depending on
names, because when I look at a method with a funny name, I might think that
the author did a bad job at naming it and "fix" the name.  However, when I
see a tag I will know that the author expects that method to be used for a
particular purpose, and I will work on learning the purpose.  So, I think
that method tags communicate better than encoding information in names.  To
me, it doesn't seem any less object-oriented than encoding info in names.
I've been programming in Smalltalk for 25 years, so I think my intuition
should count for something.

-Ralph Johnson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20100502/795b5989/attachment.htm


More information about the Squeak-dev mailing list