Object Oriented Programming vs Procedural Programming
Object Oriented Programming (OOP) and Procedural Programming are two programming paradigms. A programming paradigm is a fundamental style of computer programming, and they differ in the way different elements of the program are represented and how steps for solving problems are defined. As the name suggests, OOP focuses on representing problems using real-world objects and their behavior while, Procedural Programming deals with representing solutions to problems using procedures, which are collections of code that run in a specific order. There are programming languages that support key aspects of OOP (called OOP languages), Procedural (called Procedural languages) and both. But one important thing to note is that OOP and Procedural are two ways of representing problems to be solved, and it does not matter which language is used. In other words, OOP languages can be used for Procedural Programming while Procedural languages can sometimes be used for OOP, with some effort.
Procedural Programming is a way of programming by identifying the set of steps to solve a certain problem and the exact order that they should be executed to reach the desired outcome or state. For example, if you want to calculate the month-end closing balance for a bank account, then the required steps would be as follows. First, you acquire the starting balance of the account and then you reduce all the debit amounts occurred during the month. After that, you add all the credit amounts occurred during the month. At the end of the process, you will get the month-end closing balance of the account. One of the main concepts of Procedural Programming is the Procedure call. A procedure also known as a subroutine, method or a function contains an ordered list of instructions to be carried out. A procedure can be called at any time during the execution by any other procedure or by itself. Examples of Procedural programming languages are C and Pascal.
In OOP, the focus is on thinking about the problem to be solved in terms of real-world elements and representing the problem in terms of objects and their behavior. Object is a data structure that closely resembles some real-world object. Objects contain data fields and methods that represent attributes and behavior of real-world objects. There are several important OOP concepts such as Data abstraction, Encapsulation, Polymorphism, Messaging, Modularity and Inheritance. Some popular OOP languages are Java and C#. However, they can be used to perform Procedural Programming as well.
The key difference between OOP and Procedural Programming is that the focus of Procedural Programming is to break down the programming task in to a collection of variables and subroutines while, the focus of OOP is to break down the programming task in to objects, which encapsulate data and methods. Most notable difference could be that while Procedural Programming uses procedures to directly operate on data structures, OOP will bundle the data and methods together so that an object will operate on its own data. When it comes to the nomenclature, procedure, module, procedure call and variable in Procedural Programming are often referred to as method, object, message and attribute in OOP, respectively.