On 30/03/17 16:03, Marc Hanisch via Pharo-users wrote:
Reading this, I realized, that I never saw such type-checking in
Pharo production code. So the question is, what are recommended
design principles for that problem in Smalltalk? Do you use what is
called duck typing?

Normally I'm not interested in what an object is, but what it can do.
So a test on #respondsTo: can tell me if the object knows how to do something.

In smalltalk, I can add methods to existing classes, so there are a lot of extension methods on Object isXYZ, returning false. Morph returns true to isMorph, so all subclasses of Morph can be recognized that way.

Instead of adding a test method, there are also empty implementations
or ones that return self or an appropriate null-value.


Stephan


Reply via email to