The working of OOP inheritance
In this section, we are going to learn about an important object-oriented principle called inheritance. Before going into how it is executed in Ruby, let's see why it's important for building applications.
To start with, inheritance means your classes can have a hierarchy. It is best used when different classes have some shared responsibilities, since it would be a poor practice to duplicate code in each class for identical or even similar behavior.
For example, we have been working on our ApiConnector
class over the last few sections. Let's say we have different API classes for various platforms, but each class shares a number of common data or processes. Instead of duplicating code in each of the API connector classes, we can have one parent class with the shared data and methods. From there, we can create child classes from this parent class. With the way that inheritance works, each of the child classes will have access to the components provided from the...