Procedure Oriented Programming VS object oriented Programming

Comprehensive study notes, diagrams, and exam preparation for Procedure Oriented Programming VS object oriented Programming.

Procedure Oriented Programming VS Object Oriented Programming

Definition

Procedure Oriented Programming (POP) is a programming approach in which a program is divided into a set of procedures, functions, or routines. The main focus is on the steps or operations that must be performed, and data is usually passed from one function to another.

Object Oriented Programming (OOP) is a programming approach in which a program is designed using objects, where each object contains both data and methods. The main focus is on real-world entities, bundling data and behavior together into reusable and manageable units.


Main Content

1. Procedure Oriented Programming

  • In POP, the program is organized around functions or procedures, and each function performs a specific task.
  • The data is usually separate from the functions, and the program flow moves from one function to another based on the logic of the problem.

POP treats the program as a collection of instructions. The emphasis is on what steps are to be done first, second, third, and so on. This makes it easier to understand simple programs where the sequence of actions is fixed, such as calculating marks, printing reports, or processing simple data.

A common example of POP is writing a program with functions like calculate(), display(), and inputData(). Here, the functions do the work, and data is passed into them when needed. Languages such as C are classic examples of procedure-oriented languages.

Key characteristics of POP:

  • The top-down approach is commonly used, meaning the problem is broken into smaller tasks step by step.
  • Functions are the main building blocks, and each function may call another function.
  • Data is often global or passed as parameters, which can make large programs harder to manage.
  • It is suitable for small and medium-sized applications where the logic is straightforward.

Example:
A payroll system in POP may have separate functions for read_employee_details(), calculate_salary(), deduct_tax(), and print_slip(). Each function works on the data provided to it.


2. Object Oriented Programming

  • In OOP, the program is organized around objects, which represent real-world entities such as a student, car, bank account, or employee.
  • Each object combines data members and methods, making the program more modular and closer to real-life modeling.

OOP is based on the idea that software should be designed by identifying objects and the relationships between them. An object stores its own data and provides methods to operate on that data. For example, a Car object may have attributes like color, model, and speed, and methods like start(), accelerate(), and stop().

OOP is built on several core principles:

Encapsulation

  • Wrapping data and methods together.

Abstraction

  • Hiding unnecessary details and showing only essential features.

Inheritance

  • Creating new classes based on existing ones.

Polymorphism

  • Using one interface in many forms.

Key characteristics of OOP:

  • Programs are designed using classes and objects.
  • Data security is improved because direct access to data can be controlled.
  • Reusability is higher due to inheritance and method reuse.
  • It is suitable for large, complex, and evolving applications.

Example:
In a banking application, a BankAccount class can store account number, balance, and customer name, while methods such as deposit(), withdraw(), and checkBalance() manage the account safely.


3. Comparison Between POP and OOP

  • POP is function-centered, while OOP is object-centered.
  • POP usually separates data and functions, whereas OOP combines them into objects.

This difference leads to many practical changes in software design. POP is generally easier to learn for small programs because the focus is on writing procedures. However, as the program size grows, managing many functions and shared data becomes difficult. OOP solves many of these issues by grouping related data and behavior together.

Major differences:

Approach

  • POP follows a top-down design, while OOP often follows a bottom-up approach.

Data handling

  • POP does not strongly protect data; OOP protects data using encapsulation.

Reusability

  • POP has limited reuse, while OOP supports code reuse through inheritance and polymorphism.

Maintenance

  • POP becomes harder to maintain in large systems, while OOP is easier to extend and modify.

Real-world modeling

  • POP is less natural for modeling complex systems, while OOP maps naturally to real-world entities.

Example comparison:
If we build a student management system:

  • In POP, we may write separate functions for adding, deleting, updating, and displaying student records.
  • In OOP, we may create a Student class with methods and use objects for each student, making the system more organized and scalable.

Working / Process

1. Problem analysis and design

  • In POP, the problem is divided into a series of functions based on the steps required to solve it.
  • In OOP, the problem is first analyzed to identify objects, their attributes, and their behaviors.

2. Implementation structure

  • In POP, the programmer writes procedures that work on data passed to them or stored globally.
  • In OOP, the programmer defines classes and creates objects from those classes to perform actions.

3. Execution and interaction

  • In POP, the program executes by calling one function after another in a predefined sequence.
  • In OOP, objects interact by sending messages to each other through method calls, making the program dynamic and modular.

Advantages / Applications

POP advantages and applications

  • It is simple to understand, easy to implement for small programs, and useful where the sequence of tasks is clear, such as calculation-based applications, basic utilities, scientific programs, and command-line tools.

OOP advantages and applications

  • It improves code reusability, data security, maintainability, and scalability, making it ideal for software like banking systems, e-commerce platforms, hospital management systems, games, graphical user interfaces, and mobile applications.

Educational and practical value

  • Understanding both paradigms helps programmers choose the right approach for the right problem and improves their ability to design efficient, structured, and maintainable software.

Summary

  • POP organizes programs around procedures, while OOP organizes programs around objects.
  • POP is suitable for smaller, simpler problems, whereas OOP is better for large and complex applications.
  • OOP provides better reusability, security, and maintainability than POP.
  • Important terms to remember
  • Procedure
  • Function
  • Object
  • Class
  • Encapsulation
  • Inheritance
  • Polymorphism
  • Abstraction