Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opposite of 'Ancestor' in OOP

I am looking for the best term to use to describe a child that inherits an ancestor.

For example, a 'Car' object may derive from its ancestor 'Vehicle'. However, is there a better/more suitable word to use than derivative for the inverse?

like image 446
Niall Walker Avatar asked Jan 01 '18 20:01

Niall Walker


People also ask

What is an ancestor in programming?

Depending on your programming language, a class can have multiple parents. While an ancestor class, is any superclass of your class (a parent class, a parent of a parent class and so on).

What is inherited in OOP?

Inheritance in OOP = When a class derives from another class. The child class will inherit all the public and protected properties and methods from the parent class. In addition, it can have its own properties and methods. An inherited class is defined by using the extends keyword.

What is a descendant class?

A derived class is a class created or derived from another existing class. The existing class from which the derived class is created through the process of inheritance is known as a base class or superclass.

Does OOP have inheritance?

Inheritance is one of the most important aspects of Object Oriented Programming (OOP). The key to understanding Inheritance is that it provides code re-usability. In place of writing the same code, again and again, we can simply inherit the properties of one class into the other.


2 Answers

Ancestor/Descendant are a more common pairing when there can be intermediate layers between the items under discussion.

E.g. if we have Vehicle -> Wheeled Vehicle -> Car (and assuming other possible classes also exist), both Vehicle and Wheeled Vehicle are ancestors of Car and both Wheeled Vehicle and Car are descendants of Vehicle. We would describe Vehicle as the parent of Wheeled Vehicle and Car as a child of Wheeled Vehicle but we wouldn't generally use parent or child to describe the relationship between Vehicle and Car.

like image 144
Damien_The_Unbeliever Avatar answered Nov 07 '22 00:11

Damien_The_Unbeliever


"Inherited class" and "derived class" work well. At times instances of objects have parent/child relationships that have nothing to do with inheritance, like parent nodes and child nodes. In those cases referring to "parent" and "child" classes in the same context could be confusing.

Also, using the parent/child metaphor, every child is a parent, not every parent is a child, and some classes are infertile (sealed.)

like image 38
Scott Hannen Avatar answered Nov 07 '22 01:11

Scott Hannen