Multiple heritage

Some directed Computer programming languages objects (for example C++, Eiffel) allow the multiple heritage , in which a class can inherit behaviors and functionalities of more than super-class. Contrary to the simple heritage , in which a class inherits single a super-class.

The multiple heritage can present delicate problems, there is thus controversy on the fact of knowing if its advantages exceed its disadvantages. Java made the following compromise: The languages of Microsoft like C# and Visual BASIC implement this same approach.

The main issue which presents the multiple heritage comes from entities like a method or a member which are present several times in the ancestors of a class. For example if one defines a class App for the portable units supplied with a battery, a class Tel for the cellphones which inherits App, a class Ord for the laptops which inherits App and finally a class TelOrd for the telephones also being used of computers which inherits Ord and Tel. Then it is not known very well if the authorities of TelOrd comprise one or two batteries and under which name to differentiate them. A solution consists in adding a mechanism in the language to choose between the fusion of the repeated entities or the renaming of those in order to separate the entities. This solution is implemented in Eiffel or Ocaml to only quote most known. C++ on its side proposes the virtual heritage like less ambitious complementary tool. The smoothness of the semantic mechanisms concerned in the multiple heritage rejected many users and explains the bad reputation which it acquired in part of the community of the developers.

A second level of problems appears when it is a question of compiling or to carry out programs using of the classes with multiple heritage. Indeed in the case of call of polymorphic methods (when the same method has several versions in classes inheriting from/to each other), it is necessary to find which method must be carried out. Within the framework of a simple heritage, the ancestors of a class form a list and it is easy to create a dynamic table of connection making it possible with a simple test to find the good version. Within the framework of a multiple heritage the ancestors of a class now form a graph and the dynamic table of connection is more difficult to create. Nevertheless algorithms of compilation exist for that; it is thus possible to solve the multiple heritages with the same cost with the execution as the simple heritage. Obviously it is impossible to use these techniques with languages which are not compiled; in this case, it is necessary to traverse the graph of heritage during the execution, which can be rather long.

See too

Random links:1817 | César Borgia | 1987 concerned videos | Season 1 of the Saint | MR-8 | Park of Besancon it Mouillère | Xining