On 06.06.2004, at 19:23, Sean O'Dell wrote:
> Please go into detail on this.  Why would type checking be an 
> indication of
> weak OO design?

You can usually get rid of those checks by using polymorphism. In Ruby 
it's
possible to get rid of them without using inheritace but using duck 
typing
instead. Consider this refactoring:

class A
     def method1; warn self.class.name + ": method1"; end
end
class B
     def method1; warn self.class.name + ": method1"; end
     def method2; warn self.class.name + ": method2"; end
end

class C
     def do(*objs)
         objs.each do |o|
             if o.is_a? A
                 o.method1
             elsif o.is_a? B
                 o.method2
             else
               raise "argh!"
             end
         end
     end
end
c = C.new
c.do A.new, B.new
# =>
class A
     def method1; warn self.class.name + ": method1"; end
     def do_it; method1; end
end
class B
     def method1; warn self.class.name + ": method1"; end
     def method2; warn self.class.name + ": method2"; end
     def do_it; method2; end
end

class C
     def do(*objs)
         objs.each { |o| o.do_it }
     end
end
c = C.new
c.do A.new, B.new

Florian Frank