Skip to content

Glossary

This is a collection of the technical terms that are introduced alongside object-oriented programming.

Attribute

A variable-like member of a class. Attributes define which kinds of data are stored within a class.

Instance Attributes

These are attributes that belong directly to objects. They are defined inside the constructor.

Class Attributes

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.


Class

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


Composition

A class Ship is composed of the class SteamTurbine, if an attribute engine of the Ship is of the type SteamTurbine.

Kroki

In natural language we express this as

A Ship has a SteamTurbine as an engine.


Constructor

A special method that is called when an object is instantiated from a class. In Python its signature is __init__(self, …).


Inheritance

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 trunk)

Kroki

In natural language we say

A Car is a MotorVehicle.

Multiple Inheritance

In Python a class may have any amount of parent classes. This is called multiple inheritance. For example a Train can inherit from MotorVehicle and RailVehicle. Multiple inheritance can be very useful, but also has its very own caveats, that can be hard to debug.

Kroki

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:

  • MotorVehicle is a super-class of Car
  • Train is a sub-class of RailVehicle

Instance

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.


Member

The generic term for the components of a class, mostly refers to attributes and methods.


Method

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.


Object

A concrete instance of a class during the run of a program. The data values contained in an object are called instance attributes.