Object-oriented approach in programming: concept, application and development

Table of contents:

Object-oriented approach in programming: concept, application and development
Object-oriented approach in programming: concept, application and development

The first programming languages were imperative languages, or machine instructions (codes). They consisted of a binary code that differed depending on the machine. The set of possible instructions for such low-level "languages" was small, since each machine instruction performed a certain action (addition, copying a machine word in a register, moving to the next piece of code). Of course, for convenience, programmers developed a set of literal analogues for these machine instructions, and this way of communicating with machine hardware was called assembly language.

Punched cards first
Punched cards first


Assembly language is a low level language. Its implementation and features vary from machine to machine, from processor to processor, that is, it is platform dependent. But the essence of assembler on any machine is the same: assembler commands directly correspond to similar commandsmachines or their sequences. The difficulty in learning assembly language programming lies in the fact that the programmer is forced to study the purpose of the language directives individually for each machine, which increases the entry threshold when changing the processor.

Using an object-oriented approach
Using an object-oriented approach

The most famous assembler implementations:

  • Borland Turbo Assembler (TASM).
  • Microsoft Macro Assembler (MASM).
  • Watcom Assembler (WASM).
  • A86.

High level languages

With the development of processors, a need arose for more versatile and widely applicable tools for interacting with a computer. Over time, machine codes became very long and inconvenient to understand, so it was decided to operate with commands that are intuitively understandable to a person reading and writing code. Fortran was the first high-level computer language to use this approach. Machine commands have become readable: OPEN, CLOSE, PRINT, here for the first time the block IF statement and constructs such as IF THEN - ELSE.

Fortran language
Fortran language

Moreover, it is worth noting that after the departure of punched cards to the dustbin of history, Fortran began to support structured programming.

Structured Programming

In the 1960s and early 1970s, the development of the next programming paradigm began - structured programming, another step towards an object-oriented approach in software design. After the work of Edgar Dijkstra "On the dangers of the goto operator" from the developers of that timecomes the understanding that the work of any program can be described using only three control structures:

  • sequence;
  • branch;
  • cycle.

The goto statement has since been deemed redundant. This is a statement that allows you to jump to any block of the program. And it sometimes seems to novice programmers that there is nothing easier than using the goto statement in certain sections of the code so as not to invent new branches and loops. But in fact, the use of this operator sooner or later leads to the fact that the program turns into a "spaghetti code". Such code is impossible to maintain, painlessly modify, and worst of all, it is difficult for other developers to understand, who will replace the author of the code. This is especially dangerous in business development, where large databases are designed with thousands of lines of code. There is always turnover, and dealing with bad code is hard, especially for newcomers to the company.

object-oriented approach to programming
object-oriented approach to programming

The C Programming Language

The rise of structured programming is inextricably linked to the C programming language. This language was written in assembly language by Dennis Ritchie and Ken Thompson and became the source language for the development of the UNIX operating system. It has become the basis for many modern operating systems such as GNU/Linux, FreeBSD, MacOS, Posix and many more.

C language
C language

Due to the fact that the design of the C language is close to machine instructions, it has received the widest distribution, mainlyin various application software for a variety of devices, from video cards and operating systems to rockets and supercomputers. And its syntax has forever become the basis for many modern programming languages (C++, C, Java, Objective-C).

Object Oriented Programming (OOP)

Programs continued to become more complex, and the imperative paradigm was replaced by an understanding of the need for an object-oriented approach to information technology. Instead of the usual work with a computer using the console, graphical applications appear. The computer is no longer a highly specialized apparatus for scientific and military calculations, but a tool whose capabilities range from business automation to communicating with friends.

The main structural unit in the development of an object-oriented approach is declared a class. A class is an abstract data type created by a programmer. This is a schema, or contract, that describes the fields and methods of objects that will be created according to the patterns of this class.

For example, a person, a machine, a department is an abstraction, which means it can be described as a class. Ivan Ivanovich, white "Skoda" with numbers nn123, operations department - these are concrete representatives of these abstractions, that is, in the language of an object-oriented approach to programming, these are objects of these classes. The task of the developer is to describe the abstract and concrete objects of the real world using the OOP language. The class description is implemented in the description of its fields and methods.

the need for an object-oriented approach to information
the need for an object-oriented approach to information


Fields are variables, that is, values that characterize the work of this class. For example, if we are writing a "Car" class for a computer game, we can define the following fields for it:

class Car { string brand="Hunday Solaris"; string color="Yellow"; double speed=0; /…rest of program code…/ }


Fields can change their values during program execution, if it is provided by the programmer. If the author does not want the fields to be accessible outside the class, and some other program (user) could change their value, then he “encapsulates” the data, that is, makes them inaccessible using the keywords private, protected. If the fields should be available throughout the program, then they are preceded by public access.

For example, you can make all fields of a class public:

class Car { public string brand; public string color; public double speed; \ …rest of program code… \ }

In this case, access to these fields will not be restricted. In the user interface, it will be possible to accidentally or intentionally change important data in such fields, which will subsequently incorrectly affect the operation of the entire program:

class MainClass { public static void Main() { Car car=new Car(); car color="Red"; / …rest of program code…/ } }

To avoid accidentally changing data, the developer encapsulates it. In the case of the color of the car, instead of public, you must write private. Then the color change will directly beimpossible to do.

object-oriented approach classes
object-oriented approach classes


Methods are functions that allow you to operate on class fields or some other data. Like any functions in procedural programming languages, they accept data and can either return the result of the calculation or not (for example, output something to the console). For example:

class Car { public string brand="Hunday Solaris"; public string color="Yellow"; public double speed=0; / the “Drive” method is described below, into which the boolean variable whatIsTrafficLight is passed (with values only false - red light, or true - green light, that is, you can drive) / public void Drive(bool whatIsTrafficLight) { if (whatIsTrafficLight==true) { speed=speed + 40; } else { speed=0; } } }

As a result, using the Drive method, we change the speed of the "Car" class.


The second pillar of object-oriented development is polymorphism. Bjarne Stroustrup, the creator of the C++ language, defined polymorphism as "one interface, many implementations". In short, polymorphism is the ability to create an abstract class that describes the general design of a structure, and derived classes are already created from it that implement the missing mechanisms. For example, when creating a character in a computer game, from the point of view of an object-oriented approach, it would be logical to first implement the abstract Person class, and then create concrete classes from it: Archer, Healer, Warrior, and so on.

Or another example with a car. If we operate with one machine, with several fields and methods, it doesn't cost us anything to manually change several values in the code. But how many such machines can there be? Or, for example, users in a social network? Everyone has a first name, last name, marital status, photo album, a huge number of entries, links to other pages, to other users, and so on. And if the developers of the social network decide to redesign and change or remove some user parameters, then with this approach there will be a lot of work. The object-oriented approach solves this problem. Classes are not created for each specific object, but an abstract class is first designed, and descendant classes are created from it. Like encapsulation, polymorphism is the second most important rule of OOP.


Inheritance is another rule when using an object-oriented approach. It lies in the ability of the descendant class to use the capabilities of the parent class. For example, if we also want to have a motorcycle in our fleet, then it is not necessary to write repeating properties for the new class. Instead, we can say that the motorcycle is a class that inherits from the car. Then it becomes possible to use similar fields and methods of the car in the motorcycle class, for example, brand, color, speed. In the code, inheritance is denoted as follows:

class Motocycle: Car { /…rest of program code…/ }

Now the fields and methods of the Car parent class are available for use in the Motorcycle derived class.

In a nutshell, inheritance is a code reuse mechanism, and aims at convenient and logical extension of a program. Inheritance also helps to follow the DRY (Don't Repeat Yourself) principle. According to this principle, there should be no repeating sections in the code, because this creates an extra load when compiling and executing the program. If there are repeating sections in the code, then it must be optimized - put the repetitions into separate methods and call them as needed; apply inheritance to logically similar objects that have identical fields and methods.


The concept of object-oriented programming has been around for more than forty years, and is now the most popular way of development (except for specific areas, for example, software development for controllers, where the C language dominates). The most important OOP paradigms are:

  1. Inheritance.
  2. Polymorphism.
  3. Encapsulation.
object-oriented design approach
object-oriented design approach

With a good understanding of these powerful tools, the modern developer will be able to write fast, maintainable, visually pleasing, and modifiable code that will support business needs, bring joy to gamers, solve social problems for people, or provide communication in all corners of the world for many years to come.

Popular topic

Editor's choice