The diamond problem

Sometimes, a class inheritance diagram can take a diamond-like shape (as seen in the following diagram). This kind of class inheritance diagram can potentially lead us to a design issue known as the diamond problem:

If multiple inheritance was allowed and we encounter an inheritance tree with a diamond shape, we would not face any problems while using a method that is exclusive to only one of the classes in the inheritance tree:

var bat = new Bat(); 
bat.fly(); // OK 
bat.eat();// OK 
bat.breath();// OK 

The problem takes place when we try to invoke one of the Bat class's parent methods, and it is unclear or ambiguous which ...

Get Learning TypeScript 2.x - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.