--- 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 ---
[Pharo-users] type checking in Smalltalk
Marc Hanisch via Pharo-users Thu, 30 Mar 2017 07:04:37 -0700
- [Pharo-users] type checking in Smalltalk Marc Hanisch via Pharo-users
- Re: [Pharo-users] type checking in Small... Stephan Eggermont
- Re: [Pharo-users] type checking in S... Ben Coman
- Re: [Pharo-users] type checking ... Igor Stasenko
- Re: [Pharo-users] type check... Marc Hanisch via Pharo-users
- Re: [Pharo-users] type ... jtuc...@objektfabrik.de
- Re: [Pharo-users] type checking in Small... Alexandre Bergel
- Re: [Pharo-users] type checking in Small... Denis Kudriashov
- Re: [Pharo-users] type checking in Small... Dimitris Chloupis
- Re: [Pharo-users] type checking in S... Sven Van Caekenberghe
- Re: [Pharo-users] type checking ... Dimitris Chloupis