--- Begin Message ---
Hello,

I have a question which is more related to software engineering than to
Pharo, but I hope that someone can give me an useful hint ;-)

In Pharo By Example 5, Page 308, in the Chapter "Introspection", it is
written:

"Although these features (type inspection) are especially useful for imple-
menting development tools, they are normally not appropriate for typical
applications. Asking an object for its class, or querying it to discover
which
messages it understands, are typical signs of design problems, since they
violate the principle of encapsulation."

It is advised not to use the message isKindOf: in applications.

I do understand that it is not a good idea to do different operations
depending on the kind of an object in one method. But in my (Javascript)
production code I do a lot of checking if an argument to a function is
"instanceof" someObject. When it is not the expected type of object, an
exception is thrown. I do this to ensure that someone (=another developer)
does not by accident passes a wrong type into my method.

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?

Thanks for any advice :-)
Marc

--- End Message ---

Reply via email to