Object-oriented programming

By Karol Bocian | March 13, 2020

Object-oriented programming

The way of creating software using objects — elements combining data and functions. The program consists of objects communicating with each other and performing various tasks. It is a natural way of modeling reality for humans. The advantage of object-oriented programming is the ease of writing software, modifying, maintaining, developing and reusing code already written once.

Object-oriented programming features

Classes

Classes are object templates. They contain data (characteristics) and procedures (methods — actions to perform). For example, a class is a Circle, which contains the field: radius and the GiveFieldArea method (together with the implementation of the field calculation).

Objects

Objects are specific instances of classes. For example, the object is a Circle with radius equals 3 cm.

Basic principles of object-oriented programming

Hermetization

Hermetization consists of hiding implementation details. Objects represent a public interface that can be called by other objects. An object can only change its state. No one else can do it.

Inheritance

A mechanism that gives the possibility to create specialized objects based on more general objects. This allows you to share functionality. A specialized object can use part of the definition of a more general object and expand or change it.

Polymorphism

A mechanism to treat different objects in one way inheriting the same class.

Abstraction

Objects are models of abstract entities that perform the tasks without showing how these activities are performed. They present a simplification of an issue.

All posts from mini project: Learn SOLID and OOP principles:

Sources

Main image

Materials