Programming Paradigms or Methodologies

Programming Paradigms or Methodologies

In this article, I will give you a brief introduction to Programming Paradigms or Methodologies i.e. different programming styles. Please read our previous article where we discussed What Operating System is. The programming paradigms are the styles/methodologies of writing the code in a program. Various programming styles have been adopted depending upon the requirements. There have been different styles used since the beginning of programming languages, and we will explore a few well-known ways in this article.

  1. Monolithic Programming.
  2. Modular/ Procedural.
  3. Object-Oriented.

In today’s era, we are following an Object-oriented programming style but at the beginning, we were following the monolithic approach so let’s see what changes have occurred between them one by one.

Monolithic Programming:

In monolithic programming, the entire program code is present in a single block without any division of code into functions. Monolithic programming is defined as writing a whole program in a single function that is in the main function. A single individual can write and maintain this style of programming, much as a single artist can produce a painting. For example: Here in this example, we have written a sample code in Monolithic Programming style.

Monolithic Programming

  • It defines the programming language and how it works.
  • It is easy and faster to code in a monolithic paradigm.
  • The simplicity of code is the biggest advantage.
Disadvantages of Monolithic Programming style:
  1. The program seems to be very large and complex.
  2. Debugging, testing, and maintenance of a program are very difficult.
  3. Only one person can write a program at a time. As a result, project development might take an excessive amount of time. The code can not be divided into segments; hence the development becomes difficult.
  4. In monolithic programming, the data and the instructions are present in a single block and hence the code becomes messy and lengthy.
  5. Redundancy or repetition of the same code at multiple places is a big disadvantage.
  6. Reusability of code is not possible.
Modular/ Procedural Programming:

In this programming style, the code is written in separate blocks and not in a single block that can be used in the program whenever require without writing the entire piece of code again. Here, a particular set of code is present in the form of functions or modules that can be used wherever required. Therefore, it is called modular programming. The most popular programming language in modular programming is the C language.

Modular programming refers to the division of a program into a number of functional pieces. If the main program is separated into sub-programs, we may code each sub-module separately and then integrate them into a single unit. Individual modules of this type are referred to as functions. For example: Here in this example we have written a sample code in Modular/ Procedural style.

Modular/ Procedural Programming

Advantages of modular programming include:
  • It allows easy development of software and application by splitting down a program into smaller programs to execute a variety of tasks.
  • It increases the readability of code, makes it easier to understand the code.
  • It increases the reusability of code so that a particular piece of code can be used multiple times in a program whenever required.
  • It can be used to write bigger and complex programs.
  • A team of programmers can work simultaneously and hence big projects can be done easily.
  • It is easy to understand the program.
  • Debugging and maintenance become easy.

Example: Suppose there is an event organized in college that involves a lot of work like making arrangements and, so you can divide the work among different teams and the event can be managed easily. Similarly, the entire work(code) is divided among different functions and the program is executed easily.

Importance of the main function: The main function is the manager of the entire code of the program, it manages which block of code is to be executed and when. It is similar to a manager in a shop who manages all the work done by different people in business.

Classes in Object-Oriented Programming
  • Class – Class is a way of writing organized and structured code where the data and its associated function are encapsulated together within the class.
  • The objects can be made of class type and can be used to perform various functions.
  • The way of programming using classes is called the object-oriented programming method.
Object-Oriented Programming:

In OOPs, the code is written in the form of classes that contains different data members and member functions, the data, and their associated functions are grouped together. The objects can also be created by using class type.

We know in the modular approach we have data and function as separate entities i.e. Function can use the data from outside. But in an Object-Oriented style, we can have data and function together as one entity. This entity is called Class and we have created multiple instances of a class called Objects. For example: Here in this example we have written a sample code in Object-Oriented style.

Object-Oriented Programming

Advantages of Object-Oriented Programming:
  1. We can build the programs from standard working modules that communicate with one another, rather than having to start writing the code from scratch which leads to saving of development time and higher productivity.
  2. OOP language allows breaking the program into bit-sized problems that can be solved easily (one object at a time).
  3. OOP systems can be easily upgraded from small to large systems.
  4. The new technology promises greater programmer productivity, a better quality of software, and lesser maintenance cost.
  5. In OOPs, the code is distributed on a large scale that shows a higher level of abstraction.
  6. The class contains data and functions so the complexity is within the class, the programmer deals with the entire class.
  7. Reusability of the class within the code and outside the code is a big advantage.
Difference in Paradigms

Paradigms are just a way of writing and organizing the code but the logic and the functionality of the program remains the same.

Example: It is difficult for a person who is running the hotel to handle all the work by himself like cooking the food, serving the food, and washing the dishes, whereas if there is a division of work among people the task becomes easy. We can observe that the task remains the same but when it is handled separately by a different person, the entire work is carried out easily. Similarly, when the code is divided among functions or classes, its execution becomes easy.

Here, in this article, I try to explain Programming Paradigms or Methodologies and I hope you enjoy this Programming Paradigms or Methodologies article.

Leave a Reply

Your email address will not be published. Required fields are marked *