Twin pattern

In software engineering, the Twin pattern is a software design pattern that allows developers to model multiple inheritance in programming languages that do not support multiple inheritance.

This pattern avoids many of the problems with multiple inheritance.

These two sub-classes are closely coupled, so, both can be viewed as a Twin object having two ends.

[1] The following diagram shows the typical structure of multiple inheritance: [1] The following diagram shows the Twin pattern structure after replacing the previous multiple inheritance structure: [1] Each child class is responsible for the protocol inherited from its parent.

[1] The following code is a sketched implementation of a computer game board with moving balls.

Typical multiple inheritance
Typical multiple inheritance
Twin pattern
Twin pattern