By sleske


2011-09-21 07:22:06 8 Comments

Background:

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 delegation would have been better).

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 Liskov substitution principle (LSP) seems almost impossible to satisfy for non-trivial classes; also many other questions here seem to echo a similar opinion.

So my question:

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).

I mainly have a Java background, but I'm interested in examples from any language.

Related Questions

Sponsored Content

27 Answered Questions

[SOLVED] Why not inherit from List<T>?

6 Answered Questions

[SOLVED] Python class inherits object

35 Answered Questions

[SOLVED] Interface vs Abstract Class (general OO)

29 Answered Questions

7 Answered Questions

[SOLVED] How to call a parent class function from derived class function?

  • 2008-12-10 19:35:45
  • IaCoder
  • 636518 View
  • 600 Score
  • 7 Answer
  • Tags:   c++ oop inheritance

1 Answered Questions

6 Answered Questions

[SOLVED] What is the Concrete class in java

  • 2017-04-05 07:43:26
  • JustCode
  • 38558 View
  • 36 Score
  • 6 Answer
  • Tags:   java

5 Answered Questions

[SOLVED] Abstract class extends concrete class

Sponsored Content