Lecture
We all know that there are 2 approaches to writing a program – procedure-oriented programming (POP) and object-oriented programming (OOP). You can write a program using either of these approaches, but there are noticeable differences between them. These 2 approaches are the result of the evolution of software development that has lasted many decades. Since the invention of the computer, a great many approaches and methods of writing programs have been tried. These include such methods as Top-Down programming, Bottom-Up programming, Modular programming, Structured programming and others. The main goal of all these methods was one and the same — to make the programming process more efficient. This means making the process of writing complex programs less difficult, easy to understand, easy to extend/modify, and having as low a probability of errors appearing as possible.
Put simply, the difference between POP and OOP can be explained as follows: a programmer can handle the task of developing a program of moderate complexity reasonably well using the POP methodology, but when the program becomes more complex or is classified as a task of increased complexity, it will not be easy to write efficient code using POP. The whole programming process will become more complicated, take more time, more errors will crop up, more time will be needed to fix them, and so on. In this case OOP turns out to be much more efficient than POP. Quite complex programs can be developed much more efficiently using the OOP method. We hope you now have a general idea of the difference between the two approaches. There is no specific rule for which cases call for which method. It is all left to the programmer's discretion. However, the software development industry mostly follows the OOP methodology, since it fosters collaborative work. The main reason for this is code reuse. A piece of code developed by one programmer can be reused any number of times by any number of other programmers. This makes software development faster and more efficient.
Let us now look at each methodology separately.
The word procedure is the key element here. It means a set of procedures, which represents a set of subroutines or a set of functions. We all know about functions in the C language. C is a procedure-oriented language. In POP the main focus is on functions or subroutines. Functions contain a set of commands that perform a specific task. Functions in a program are called repeatedly to perform certain tasks. For example, a program might include collecting data from the user (reading), performing some kind of calculation on the collected data (computing), and displaying the results at the user's request (output). All three of these tasks, reading, computing and outputting results, can be written into the program using three different functions performing three different tasks.

Structure of the POP methodology
The problem with applying POP lies in data handling. In POP no significance is attached to data. By data we mean information received from the user, new results obtained after calculations, and so on. If you are familiar with programming in C, you may recall the storage classes of that language. In C, a data item (variable) must be declared as GLOBAL in order for it to be accessible to two or more functions of the program. What happens when 2 or more functions work with the same data item? If a program has 10 functions, then all 10 of these functions can access the global variable. It is quite possible that one function might accidentally change the value of this global variable. And if it is a key element of the program, any such accidental manipulation will affect the entire program. Then it will be too difficult to debug and identify the function causing the problems, especially if the program is very large.

Working with data and functions in POP
One of the most important features of the C language is structures. Anyone familiar with this language will recall that structures in C are declared using the keyword struct. Structures allow different types of data to be packed together into a single whole. A programmer can pack integer data, floating-point numbers (float), arrays and other kinds of data into a single object using a structure. The way of programming with structures was first introduced in the C language, and this was one of the main reasons for this language's great popularity. And what is the real reason for this? A structure models the requirements of the real world in a computer program quite well. The problem associated with structures was that they only worked with data. A structure does not allow related functions to be packed together alongside the data. All functions that manipulate the data items inside a structure must be written separately within the program. For this reason a C program has a large dependency on functions.
When the POP approach is applied, a problem is viewed as a sequence of tasks, which might be implemented as reading, performing calculations, outputting the result, and so on. All tasks are first analyzed, and then functions/procedures are developed to carry out all these tasks.
The OOP method differs from POP in its basic approach. OOP was developed while preserving all the best features of the structured programming method, which was supplemented with a host of concepts that promote efficient programming. OOP offers many capabilities, and it creates an entirely new way of writing programs. In general, OOP has inherited all the best features of the POP methodology, such as functions/procedures, structures, and so on.
The first feature of OOP that programmers would mention is data hiding (encapsulation). OOP attaches enormous importance to data. A programmer can hide truly important key data from the outside world using OOP tools. The basic concept of OOP is based on a notion similar to the notion of a structure in POP, called a class. A class is an important feature of OOP; it allows different types of data to be packed together alongside various functions that manipulate the data items of that class. Data items inside a class can be declared as local (private) or global (public). In order to hide data from the outside world, the programmer must declare it as private. In general, a class really is similar to a structure in the C language. Like any structure, it combines various objects into a single whole. The main difference between a class and a structure lies in functions. Structures do not allow data and functions to be combined together (structures work only with data), whereas classes allow data to be packed together with functions related to it. In addition, there are further differences, such as hiding data using private/public. Structures do not make it easy to hide data. In a structure, its elements are accessed using so-called structure variables. OOP uses a different notion for accessing data and functions inside a class — the object. The data and functions inside a class are called members or elements of the class. A class member can be accessed from the outside world (outside the class) only through an object of the class.

The ability to hide data is called data encapsulation. In this way, one of the main drawbacks of POP is solved in OOP. OOP closely ties data to a specific class and its objects. There is no need here for global data types as in POP, and, consequently, data cannot freely “flow” throughout the whole program. This guarantees that no accidental modification of important data will occur.
Another feature brought into OOP is the possibility of code reuse. This simply means that a piece of code that was written earlier can be used in the future. This became possible thanks to a feature of classes called inheritance. Thanks to inheritance, one class can acquire the properties of another class. This can be explained with a simple example. Let's take a school management system. Initially the management decided to develop a program focused only on students (without accounting for teacher data). The programmer did an excellent job, and in the process of programming he declared a class for collecting personal data, such as name, age, gender, address, etc. A year later the school administration decided to include teacher data in the list. Now the programmer is able to add this data in a very short time, since he can use many parts of the code he wrote earlier, thanks to inheritance. The personal data class is general in nature (age, gender, etc. are the same for a person regardless of whether they are a teacher or a student). The programmer can inherit this class into a new class, and also extend it with new fields, for example a field for a teacher's qualification.
OOP has many more capabilities, such as polymorphism (operator and function overloading), dynamic binding, and so on. You can read about all of this in the relevant literature.
Comments