Extending an object’s behaviors with inheritance
Here we are at our discussion of one of the core features of OOP. The ability to reference and implement a class by simply inheriting its behaviors and properties is what we’ll be talking about here. Loved by few, criticized by many, inheritance is usually what comes to developers’ minds when we talk about OOP, even though this paradigm is more about bundling data and procedures into the same data structure. Inheritance is the trademark feature of OOP.
One of the main critiques of inheritance is that, by definition, it creates a hard coupling between classes, namely the super-class and the subclass (or parent class and child class, or general class and specialized class). Usually, people are against coupling classes because it makes it harder to maintain them once the project starts to scale. A simple change in a class may break its user classes’ code. This can be mitigated with good interfaces. Again,...