Simplifying your point, you should not declare that A "isa" B unless A really is a B. Barbara Liskov would agree.

If you find yourself using OOinheritance for polymorphism, and then having to insert if checks to correct that polymorphism, you have a problem. Clearly the polymorphism is not really doing what you want it to do, and as your object hierarchy spreads out, it will need ever more correction.

A good general rule is presented in Code Complete 2 (p 149, section 6.3):

This section has presented numerous rules for staying out of trouble with inheritance. The underlying message of all these rules is that inheritance tends to work against the primary technical imperative you have as a programmer, which is to manage complexity. For the sake of controlling complexity, you should maintain a heavy bias against inheritance.
(Emphasis in original.)

Therefore only inherit when it obviously is right to so, and view with extreme doubt anything that increases the complexity of maintaining that inheritance. If it isn't perfect, don't do it.

Update: Modified per chromatic's note


In reply to Re: "if" Considered Harmful in OO programming by tilly
in thread "if" Considered Harmful in OO programming by Ovid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.