Note that there are some explanatory texts on larger screens.

plurals
  1. POAny good examples of inheriting from a concrete class?
    primarykey
    data
    text
    <p><strong>Background:</strong> </p> <p>As a Java programmer, I extensively inherit (rather: implement) from interfaces, and sometimes I design abstract base classes. However, I have never really felt the need to subclass a concrete (non-abstract) class (in the cases where I did it, it later turned out that another solution, such as <a href="http://en.wikipedia.org/wiki/Delegation_pattern" rel="nofollow noreferrer">delegation</a> would have been better).</p> <p>So now I'm beginning to feel that there is almost no situation where inheriting from a concrete class is appropriate. For one thing, the <a href="http://en.wikipedia.org/wiki/Liskov_substitution_principle" rel="nofollow noreferrer">Liskov substitution principle</a> (LSP) seems almost impossible to satisfy for non-trivial classes; also <a href="https://stackoverflow.com/questions/269496/inheritance-vs-aggregation">many</a> other <a href="https://stackoverflow.com/questions/3887871/is-inheritence-of-concrete-classes-evil">questions</a> here seem to echo a similar opinion.</p> <p><strong>So my question:</strong> </p> <p>In which situation (if any) does it actually make sense to inherit from a concrete class? Can you give a concrete, real-world example of a class that inherits from another concrete class, where you feel this is the best design given the constraints? I'b be particularly interested in examples that satisfy the LSP (or examples where satisfying LSP seems unimportant).</p> <p>I mainly have a Java background, but I'm interested in examples from any language.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload