This is a collection of the technical terms that are introduced alongside object-oriented programming.
These are attributes that belong directly to objects. They are defined inside the constructor.
These are attributes which belong directly to the class and are defined on the class level. All instances of a class share these same attributes.
Each class is a definition of a data format. It consists of members which can be attributes or methods. Each class is by definition a data type. Classes can be combined by using composition and extended and modified via inheritance
Ship is composed of the class
SteamTurbine, if an attribute
engine of the
Ship is of the type
In natural language we express this as
If a class
Car inherits from
MotorVehicle it takes over all pre-existing attributes and methods of the parent class.
It can replace (override) the inherited methods with its own implementation.
The inheriting class can add its own members as well. (e.g. a
Car may additionally have a
In natural language we say
In Python a class may have any amount of parent classes.
This is called multiple inheritance.
For example a
Train can inherit from
Multiple inheritance can be very useful, but also has its very own caveats, that can be hard to debug.
Super- and Sub-Classes
A class that is more general is called a Super-class of a more specific one, which in turn is a Sub-class. For example:
MotorVehicleis a super-class of
Trainis a sub-class of
An object is considered to be an instance of a class if the class (or one of its sub-classes) is the data type of the object. Objects get created from classes during the instantiation which involves the constructor-call.
A function-like construct in the context of a class. By default it operates on a specific object for which the method is called. Methods that operate on a class itself are called class methods. Methods that are members of a class but do neither require an object nor the class itself for context are called static methods.