4. Inheritance

When two classes have a lot of common information, this common information can be shared by the classes by extracting it and putting it in another class. All the common characteristics are collected under one specific class and the original classes inherit them from it.

Figure 1.4. Classes inheritance

Classes inheritance

4.1. Advantages

  • Using inheritance, common descriptions can be reused, promoting the concept of code reusability;

    Inheritance cuts redundancy as descendant classes only implement the extra information that differentiates them (It leads to smaller, easier to understand systems);

    When modifications are implemented on the common information all descendant classes automatically inherit it (This helps create models that are easier to modify and evolve).

4.2. Audio

Audio in Portuguese