[Newbies] Re: A Question of Style

Stuart Herring st-lists at stuartherring.com
Sun Apr 1 10:05:35 UTC 2007

On 4/1/07, Klaus D. Witzel <klaus.witzel at cobss.com> wrote:
> > Smalltalk With Style makes this very clear.  It definitely
> > prefers that I communicate with Vendor in the language of a Vendor, and
> > not in the language of a Dictionary.
> The #at:put: vocabulary is part of the language of Smalltalk, which is
> universal and independent of Vendor language. You do not implement
> Smalltalk in the labguage of Vendor but, the opposite direction is the
> case. This is inevitable and the language direction is irreversable.
If I were examining the methods of Vendor, and I saw priceAt: put:
then yes, I'd realise that I was witnessing some sort of Dictionary
like API, but my two questions would be "at what?" and "what am I
putting?".  You could probably guess that it wanted an item and a
price, but the wording seems to imply it wants the price as the key,
and the item as the value.  I'd probably have to end up looking at the
implementation to make sure which way round it wanted it.
If I saw #priceOf:is: or #setPriceOf:to:,it'd be far more obvious what
was going on.

To insist on #at:put simply because it's what's used by a Dictionary
seems wrong, because it's not the interface to the price book that's
in question, it's the interface to the Vendor, and in this case
creates an awkward feeling API - much like dogmatic adherence to some
English style guides creates awkward sentences (as in the apocryphal
Churchill quote: "This is the sort of English up with which I will not

Maybe this discussion is a sign that it would make more sense to
expose the price book separately, rather than put the price setting
messages on the vendor itself?
The pricebook would then have #at:put, because it certainly is a
collection, and by being a pricebook it's obvious what the key and
value should be.

so rather than "aVendor priceOf: #foo is: price" or "aVendor priceAt:
#foo put: price",
you'd have:  "aVendor pricebook at: #foo put: price"

This seems to satisfy both the condition of using the language of the
domain, and provides the familiarity of the dictionary interface.


More information about the Beginners mailing list