top of page

Procedural and Functional vs OO design

Procedural and object oriented are two different programming paradigms. Today we will take a look at what are the characteristics of each of them, which programming languages are created based on them and their differences.




What is procedural programming ?

In procedural programming the whole program is divided into several procedure calls. A procedure call is a series of computational steps which can be contained in a procedure. The procedures are called in a sequence by a parent procedure to complete a task. In procedural programming each procedure can work on shared data and even can change the state of the variables that contain data.

Many of the old programming languages are procedural. Starting from BASIC, COBOL, ABAP, Fortran.

What is functional programming ?

In functional programming the code is divided into mathematical functions. Its type of structural programming. Though each function contains a series of computational statements, as opposed to the procedural programming here the change in state of variables is avoided. Here data is passed from function to function, each function processed data and returns result in the format of data. A function can also be passed to other functions or can be returned. C is a pure functional programming language.

What is object oriented(OO) programming ?

The first programming language that was considered as object oriented Java. Python and Groovy are also considered as object oriented languages.

C# and C++ are functional programming languages with object oriented features. JavaScript is also a language that can function both as procedural and object oriented with very simple object oriented constructs.

The functional programming model follows a hierarchy, and is data driven. The data is passed from one function to another and each function does some specific operation using the data and changes the data accordingly(if needed). The data enters at the top of the hierarchy and moves down through the hierarchy. The object oriented programming model can be perceived as a network of objects , existing individually and used by one another to perform some task. The objects themselves are responsible to maintain their own data and state, they communicate by sending messages to one another. One object calls (some time creating on its own) another object's methods, and passes minimal data as method arguments required to provide some information. Sometimes these objects die as soon as their use is finished. The time they live on their own (like separate thread) and communicate when needed. This way of calling methods to communicate is called messaging between objects. As you might know, in OO programming we differentiate functions and methods. Functions are internal to a class that manages a chuck of code, methods are interfaces that are visible to other objects and can be used for messaging.

The sender and the receiver of the message should not know each other or know as little as possible. In that way the sender can send a message to some other class to get the work done. A receiver can also be used by several senders.

There are many other types of programming paradigm like event driven programming paradigm. Wikipedia has a list of programming paradigms.


bottom of page