The Advantages of Multiple Inheritances

104 14

    Object-Oriented Programming

    • Object-oriented programming (OOP) is the dominant programming paradigm in the enterprise programming space. Instead of viewing programming as handing a computer a list of instructions to execute, Object Oriented Programmers build up discrete objects in memory and then orchestrate these objects to produce working software. The object-oriented approach, when well executed, produces modular software that's easy to test.

    Classes and Inheritance

    • Classes are a fundamental part of object oriented programming. Classes act as a "factory" for other objects, they create other objects. OOP programmers spend most of their time defining classes that exhibit various behaviors they need to write software. Classes may inherit from other classes, or copy their behavior. Classes that inherit from another class are said to be a sub-class of that class. Most OO languages are single-inheritance, classes may only inherit from one class. Multiple inheritance allows classes to inherit from more than one other class.

    Multiple Inheritance

    • Multiple Inheritance is not very widespread. It can produce software that's difficult to work with and opens classes up to all kinds of problems. For instance, a programmer could "sub-class" two different classes with conflicting behavior. This could cause huge debugging headaches. On the other hand, from a hierarchies-of-type point of view, an object may belong to more than one type. For instance, a dragonfly might belong to both class "insect" and class "flyable." Multiple inheritance is convenient from a "types" standpoint.

    Alternatives to Multiple Inheritance

    • There have been attempts to develop alternatives to multiple inheritance that solve some of the issues associated with the concept, while also enabling programmers to reap some of the benefits. One of the most promising approaches is "mix-ins" which allow programmers to define special classes that may be mixed into other classes. If these classes define conflicting behavior, the behavior that belongs to an actual class supersedes the mix-in behavior.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.