Compare object oriented system with procedure oriented system. Also explain the concept of encapsulation.


Q.) Compare object oriented system with procedure oriented system. Also explain the concept of encapsulation.

Subject: Object Oriented Programming and Methodology

Object-Oriented System vs. Procedure-Oriented System

Object-Oriented System (OOS)

  • Definition: OOS is a programming paradigm that revolves around the concept of objects. Objects are entities that combine data and behavior, and they interact with each other through methods.
  • Key Features:
    • Encapsulation: Bundling data and methods together into a single unit.
    • Abstraction: Hiding the implementation details of an object from the user.
    • Inheritance: Creating new classes from existing classes, inheriting their properties and behaviors.
    • Polymorphism: Allowing objects of different classes to respond to the same method call in different ways.
  • Advantages:
    • Improved code organization and maintainability.
    • Reusability of code through inheritance and polymorphism.
    • Increased flexibility and extensibility.
  • Disadvantages:
    • Can be more complex to design and implement than procedure-oriented systems.
    • May require more memory and processing resources.

Procedure-Oriented System (POS)

  • Definition: POS is a programming paradigm that focuses on the execution of a series of procedures or functions. The data and the logic to manipulate it are typically separated.
  • Key Features:
    • Emphasis on procedural flow and control structures.
    • Data and functions are often stored separately.
    • Subroutines are used to break down tasks into smaller, reusable units.
  • Advantages:
    • Simpler to design and implement than object-oriented systems.
    • May be more efficient in terms of memory and processing resources.
  • Disadvantages:
    • Code can become difficult to organize and maintain as it grows.
    • Limited reusability of code.
    • Less flexible and extensible than object-oriented systems.

Encapsulation

  • Definition: Encapsulation is a fundamental concept in object-oriented programming that refers to the bundling of data and methods into a single unit, known as an object. This bundling helps to protect the data from external access and modification, ensuring that it remains consistent and secure.
  • Key Points:
    • Encapsulation allows for better data hiding, as the internal details of an object are hidden from the outside world.
    • It promotes modularity and code reusability, as objects can be easily combined and reused in different programs.
    • Encapsulation enhances security by restricting access to sensitive data and methods.
  • Examples:
    • A bank account object encapsulates the account number, balance, and methods for depositing and withdrawing money.
    • A student object encapsulates the student's name, ID, and methods for calculating their GPA and generating a transcript.

In summary, object-oriented systems offer a more structured and modular approach to programming compared to procedure-oriented systems. Encapsulation is a crucial aspect of object-oriented programming that promotes data hiding, modularity, and security.