archmeta
archmeta

Reputation: 1127

What is the opposite of a base class in OOP?

In object-oriented programming, a 'base class' is a class from which other classes have been derived (http://en.wikipedia.org/wiki/Base_class).

However, what is the opposite of a base class? In order words, what is a class that does NOT have any child classes called?

EDIT: I am looking for the name of a class that has not been sub-classed, YET, within an inheritance of tree of multiple parent classes, starting with a base class.

Upvotes: 14

Views: 7566

Answers (5)

Stainedart
Stainedart

Reputation: 1979

It would be called a leaf class.

https://en.wikipedia.org/wiki/Leaf_class_(computer_programming)

Upvotes: 4

Jordão
Jordão

Reputation: 56497

A base class is a relative term. It only applies when considering one of its derived classes. Here are some terms that I consider opposites (and mostly orthogonal among themselves):

  • base class vs derived class; similarly super class vs sub class
  • abstract class vs concrete class
  • root class vs leaf class
  • sealed (also, final) class vs inheritable (non-sealed) class
  • nested class vs top-level class

Abstract and (normally) root classes are designed to be base classes. Sealed classes cannot be base classes, because they're non-inheritable. A root class is a class without a base class (in C# and Java, this class is Object). A leaf class has no subclass, so it's not a base class; but it's not necessarily sealed. Sealed classes, on the other hand, are always leaf classes.

So,

I am looking for the name of a class that has not been sub-classed, YET

It seems that you're looking for a leaf class, but I don't consider it to be the opposite of a base class.

Upvotes: 24

Brandon Moore
Brandon Moore

Reputation: 8780

I sealed class doesn't have to inherit from anything. To me the opposite of a base class would be a derived class, but being a derived class doesn't preclude it from being inherited from.

But it sounds like Carl T.'s answer is probably what you were looking for.

Upvotes: 1

0x5f3759df
0x5f3759df

Reputation: 2359

I usually hear leaf class. Java enforces it with final.

Upvotes: 4

kol
kol

Reputation: 28708

In C#, these are called sealed classes. You can use the keyword sealed to indicate that a class is not to be inherited from. VB uses the keyword NotInheritable. Wikipedia calls them non-subclassable.

Upvotes: 1

Related Questions