Object>>caseOf: (was Re: [Q] Enum style Object?)

goran.hultgren at bluefish.se goran.hultgren at bluefish.se
Sun Feb 23 19:24:56 UTC 2003

Hi all!

Ned Konz <ned at bike-nomad.com> wrote:
> On Wednesday 19 February 2003 01:54 am, Hannes Hirzel wrote:
> > But I'm not sure if this is better than the code snippet above. At
> > least it is rare style.
> > I didn't even know that Object>>caseOf: exists!
> > In my current 'productive' 3.5alpha image there are only three
> > senders of this method:
> > two in MessageNode and one in MethodFinder.
> >
> > Smalltalk teachers and traditionalists out there - what do you
> > think?
> I like it. I use it. It produces good code.

I agree. There are times when a caseOf: is very suitable. Of course, OO
beginners may get seduced into using it when they are in fact not doing
OO properly. But hey, there are lots of ways to do "bad code" anyway.

When I have taught OO I have also used the "mantra" that the students
should stay away from if-statements as much as they can since they are
in fact (when appearing in herds) a sign of missing objects (which can
eliminate the if-statements by using polymorphism).

regards, Göran

More information about the Squeak-dev mailing list