join
Lex Spoon
lex at cc.gatech.edu
Mon Sep 18 10:03:22 UTC 2006
Andreas Raab <andreas.raab at gmx.de> writes:
> > join: anOrderedCollection
>
> It would be good to give this a role instead of a type name. From the
> type name it's not immediately obvious whether:
> 'abc' join: 'xyz'
> results in 'axyzbxyzc' or 'xabcyabcz'.
Yeah, you can only learn the behavior by experience. It would be
better if the name just gave away the behavior.
> > "Implicit precondition: my elements are all OrderedCollections"
>
> The precondition should probably be that "receiver species = argument
> species" and consequently determine the result species.
Actually, it might be nice to make this produce *strings*. That's
what most people seem to want the method for. It's hard to think of a good name that is shorter than the implementation, but maybe:
joinStringsWith:
printStrings:
makeString:
Join is popular for people who use Perl, but it seems weird if there's
a print involved in the method. printStrings: can be misread in
several ways, e.g. does it return the print strings? Does it print
the argument's elmeents, which are expected to be strings?
I lean towards makeString:, though I admit I have different and warped
experience that makes this one look familiar to me. That said,
makeString: does tell you the most important thing about the method--
it flattens the receiver into a string. It is vague about how it does
it, but in most use cases the reader can guess (foo makeString: ', ').
-Lex
More information about the Squeak-dev
mailing list
|