A use for multiple inheritance?

Most uses of full scale Multiple inheritance are for mixins. As an example: class DraggableWindow : Window, Draggable { } class SkinnableWindow : Window, Skinnable { } class DraggableSkinnableWindow : Window, Draggable, Skinnable { } etc… In most cases, it’s best to use multiple inheritance to do strictly interface inheritance. class DraggableWindow : Window, IDraggable … Read more

Diamond Problem

Its not the same problem. In the original problem, the overriden method can be called from A. In your problem this can’t be the case because it does not exist. In the diamond problem, the clash happens if class A calls the method Foo. Normally this is no problem. But in class D you can … Read more

Mixin vs inheritance

A mixin is typically used with multiple inheritance. So, in that sense, there’s “no difference”. The detail is that a mixin is rarely useful as a standalone object. For example, say you have a mixin named “ColorAndDimension”, which adds a color property and width and height. Now, you could add ColorAndDimension to a, say, Shape … Read more

Why not use instanceof operator in OOP design?

instanceof simply breaks the Open/Close principle. and/or Liskov substitution principle If we are not enough abstract because of instanceof usage, each time a new subclass makes an entrance, the main code gathering the logic of the application might be updated. This is clearly not what we want, since it could potentially break the existing code … Read more