Please see my other Object-Oriented Programming (OOP) articles.
Modeling Real-World Objects through Relationship
As demonstrated by my Object-Oriented Programming (OOP) articles, OOP provide several mechanisms for code reuse, such as class inheritance.
These mechanisms work by relationships which may exist between classes.
Is-A Relationship (Inheritance)
Inheritance demonstrates the first type of relationship – is-a, where one class (Supervisor) “is-a” type of another class (Employee), and therefore inherits from that class.
Has-A Relationship
Composition demonstrates another type of inheritance with a different type of relationship.
For example, each employee has a family.
Since the relationship between family and employee does not constitute an “is-a” type of relationship – a family is not a type of an employee, but an employee “has-a” family (optionally), the Employee class “has-a” Family class.