does squeak have an equivalent of #askFor:

goran at krampe.se goran at krampe.se
Sun Aug 13 21:42:31 UTC 2006


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.

regards, Göran



More information about the Squeak-dev mailing list