I'll start with a bit of background.
I know that for a good period of time, inheritance was all the rage - it got used left and right to solve all sorts of problems. Since then, there seems to be a backing-off, with a realization that inheritance also carries a number of problems, and maybe there are other tools available that could solve some of those problems in better ways.
For example, often inheritance is used to customize the behavior of a particular class. Instead, the class can provide hooks into its behavior, which allow customization during construction. This is called the "strategy pattern", and it gives the class more power over what can and can not be customized, and generally results in more readable code on the end-user's side over an inheritance solution.
Another example: Often inheritance is used purely for the purposes of publicly exposing the fact that two different types can be used interchangeably (i.e. polymorphism). This can be done through the upcoming protocol proposal instead.
So, here are my discussion questions:
- What are some other use cases for inheritance?
- When should inheritance be used (if ever)?
- When should inheritance be avoided?