[Newbies] Re: Re: A Question of Style

Klaus D. Witzel klaus.witzel at cobss.com
Sun Apr 1 10:27:32 UTC 2007

+ 1

and I couldn't have worded it better :)

IHMO (and perhaps only there) an object is allowed to pretend to *also* be  
something else (aVendor pretends to be aPricebook, in the #priceAt:put:  
example) *only if* it could effectively take that role.

If not or in doubt: delegate to someone who lives that role [talk small  
and create great things].


On Sun, 01 Apr 2007 12:05:35 +0200, Stuart Herring wrote:

> 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
> put").
> 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.
> Regards,
> Stuart

More information about the Beginners mailing list