[Newbies] isKindOf considered questionable

stan shepherd squeak414 at free.fr
Sat Jun 21 19:46:17 UTC 2008

matthewf wrote:
> On Sat, Jun 21, 2008 at 08:13:48AM -0700, stan shepherd wrote:
>> Hi, I'm using isKindOf as part of my unit tests,
>> self should: [(mare maternalStrand at: 100)
>> 								isKindOf: Gene];
>> When I run through the code critics, isKindOf is flagged as a
>> 'questionable
>> message'. I can't find any reference to why it should be so; can someone
>> explain please?
> It is considered bad when isKindOf: is used in the following
> way:
> (anObject isKindOf: String) ifTrue: [anObject size]
> It is good design to let an object decide what to do when it
> recieves a message, rather than using isKindOf: to decide
> whether you should send an object one message and not another.
> The reason being that, someone may want to use a different kind
> of object that respects the String protocol.
> Objects are better classified by what messages they respond to,
> not what class they may be.
> For unit tests, this is a good use for it, though.
> -- 
> Matthew Fulmer -- http://mtfulmer.wordpress.com/

Thanks,   that makes sense.
View this message in context: http://www.nabble.com/isKindOf-considered-questionable-tp18045399p18048078.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.

More information about the Beginners mailing list