does squeak have an equivalent of #askFor:

Giovanni Corriga giovanni at corriga.net
Wed Aug 16 10:05:10 UTC 2006


Il giorno dom, 13/08/2006 alle 23.42 +0200, goran at krampe.se ha scritto:
> Hi!
> 
> "Diego Fernandez" <diegof79 at gmail.com> wrote:
> > On 8/12/06, Keith Hodges <keith_hodges at yahoo.co.uk> wrote:
> > > Diego Fernandez wrote:
> > > > Ouch!
> > > > IMHO a lot of #isThis or #isThat shows the lack of some abstractions.
> > > > Maybe you can solve it a better way.
> > > >
> > > why?
> > 
> > Because if you have an object that responds to isBanana method, you
> > end with code like this:
> > anObject isBanana ifTrue: [ "do something with anObject" ]
> >                              ifFalse: [ "do another thing with anObject" ].
> 
> And I fully agree of course. Normally the perceived need for an isBanana
> message *can and should* be solved using a different design leveraging
> polymorphism/delegation properly. BUT... in design there are always
> tradeoffs and sometimes you just decide that an isBanan message is still
> the way you want to go. At leat that is my experience, perhaps I could
> have redesigned my way around the isBananas that I have written - but I
> doubt it.

I find the isBanana-style messages are useful when I have a collection
of diverse objects, and I want to retrieve Bananas only:

	aCollection select: [:each | each isBanana ]

	Giovanni	




More information about the Squeak-dev mailing list