Object Oriented Programming
Schema vector image Circle vector image 1 Circle vector image 2 Circle vector image 3

Procedural and object-oriented programming

Updated: August 3, 2022 07:41

There are few types of programming. In this article, we will be focused on procedural and object-oriented programming (OOP). Most of the popular programming languages have possibility to code in OOP way. But what is the difference between procedural and object-oriented programming?

Object-Oriented programming

PHP OOP

OOP (Object-Oriented programming) is dividing software in different objects, where every object has its own purpose. To illustrate, let's imagine a carpenter who constructs a table. He makes objects like tabletop and table-legs, at the end he unites all to one table. OOP programmers think about other programmers who can access and modify code later. So, in OOP symbolically, a carpenter gives opportunity to other carpenters to change objects like legs and table-top. And, other carpenter can even make a drawer in the table. So, future programmers can easily customize and extend code. Complexed CMSs like Drupal are made in OOP. So, objects are divided to Users, Content, Configuration, Appearance, ... and their sub-objects.

Procedural programming

PHP Procedural

It is making code from one piece. For example, a carpenter can make a table from just one piece of wood, so the legs and tabletop will all be just from one part, that is like procedural programming. How can a carpenter change a broken leg from a table constructed from one piece of wood, or make the table-top wider? He can, but it's very difficult! So, it is difficult for future programmers to extend code, or make changes.

Difference between procedural and object-oriented programming

Advantages of procedural programming are:

  • Smaller code;
  • Consumes less resources;

So, disadvantages of procedural programming are fewer and harder, extending possibilities. Also, other programmers have big problems to find and fix bugs. Procedural programming is a good choice for smaller and temporary projects. For huge projects, procedural programming is a poor solution, OOP is a much better choice. Because, code is cleaner, divided into objects with much easier and understandable access.

Advantages of OOP are:

  • Data encapsulation, which gives more secure software;
  • Access to modification without changing core codes;

Also, software made in OOP can be easily updated and upgraded to newer versions. Instead of completely changing code for upgrade, what is mostly case in procedural programming, in OOP, programmer just change deprecated code. But OOP is more robust than procedural programming, has more code and consumes more resources. Software can also be programmed in combined way, procedural and object-oriented programming. So some parts are procedural programmed, but also some are in OOP.

Drupal from version 8 is made in the PHP OOP programming model. Thanks to OOP, upgrading from Drupal 8 to Drupal 9, was much easier, than it was from Drupal 7 to Drupal 8. Because, Drupal 7 was made in procedural programming way, and Drupal 8 in OOP. After Drupal 8, all next versions will be much easier to upgrade.

Programming languages that support OOP

Most of the programming languages are firstly made for procedural programming and in later versions have been modified for OOP. For example, PHP was founded in 1994, but only after ten years in version PHP 5, it got new feature, support for Object-Oriented programming. But now, most of new programming languages have support for OOP:

  • PHP;
  • JavaScript;
  • Java;
  • C++;
  • C#;
  • Python; ...

Popular CMSs and CMFs in procedural and object-oriented programming

Almost every CMF is made in OOP. Because, CMFs have a great need for extension. CMSs are programmed in procedural and object-oriented programming. These are list of popular CMSs and CMFs with way of programming:

  • Drupal is fully made in OOP;
  • Symfony is fully made in OOP;
  • WordPress is made in procedural programming, but extensions can be made in OOP;
  • Laravel is made in OOP;
  • Joomla is mostly in OOP;
  • Django itself is not made in OOP, but extensions, yes.

Because of high security, eDot.pro for our clients, gives Drupal CMS which is made in OOP.