Unit 5: Object Oriented Programming - CS Study Hub

Latest

Sunday, December 7, 2025

Unit 5: Object Oriented Programming


Programming Paradigm (What are the programming methods or approaches of program development?)

A programming paradigm is like a set of rules or methods that programmers follow when they write code. It's like a way of thinking about and organizing the tasks they want the computer to do. Different paradigms have different approaches to problem-solving and writing code. The two main types of programming paradigms are: Procedure Oriented Programming (POP) and Object-Oriented Programming (OOP). Procedure Oriented Programming is a traditional method of programming and Object-Oriented Programming is a modern method of programming.

Procedure Oriented Programming (POP)

Procedure-oriented programming is a programming paradigm that focuses on writing code as a series of procedures or functions to perform specific tasks. In this approach, the program is divided into smaller, manageable procedures, each responsible for a particular action.

These procedures can call one another to achieve more complex tasks, with data being passed between them as needed. The emphasis is on breaking down a problem into smaller parts and solving them sequentially.

Features of Procedure Oriented Programming

    1. Programs are divided into smaller modules or procedures for better organization.
    2. Procedures hide implementation details for simplicity.
    3. Code is executed one step at a time, following a top-down approach.
    4. Simple data structures like arrays are used for data manipulation.
    5. There’s less focus on data hiding and encapsulation compared to other paradigms.

Object Oriented Programming (OOP)

Object-oriented programming (OOP) is a programming paradigm where we think about and design our code based on real-world objects and interactions. In OOP, we create "classes" to define what these objects can do and what data they can hold. Then, we use these classes to create "objects" in our code, which we can interact with and manipulate. OOP helps us write more organized and reusable code by breaking it down into smaller, self-contained pieces.

Characteristics of OOP

    1. Emphasis is given to the data.
    2. Programs are divided into multiple objects.
    3. Functions and data are tied together in a single unit.
    4. Data can be hidden to prevent accidental alteration.
    5. It follows the bottom-up approach.

Features of OOP:

Class:

A class in object-oriented programming is like a blueprint or template for creating objects. It defines the properties (attributes) and behaviors (methods) that objects of that class will have. Instances of a class, called objects, inherit these properties and behaviors, allowing for code reuse and abstraction.

Object:

An object in object-oriented programming is a concrete instance of a class. It represents a real-world entity with properties (attributes) and behaviors (methods) defined by its class. Objects encapsulate data and functionality, allowing for modular and organized code that models real-world interactions.

Abstraction:

Abstraction in programming refers to simplifying complex systems by focusing on essential characteristics while hiding unnecessary details. It means focusing on the important parts of something while ignoring the details that aren't necessary right now. It’s like using a remote control without knowing exactly how it works inside—it just does what you need it to do. Abstraction helps make things easier to understand and work with by hiding the complicated stuff.

Inheritance:

In object-oriented programming, inheritance is a mechanism that allows a new class to inherit properties and methods from an existing class. It is like passing down traits from parents to children. It allows a new class (the child class) to inherit properties and behaviors from an existing class (the parent class). This promotes code reuse, simplifies implementation, and supports hierarchical relationships between classes.

Encapsulation:

Encapsulation in object-oriented programming (OOP) refers to the bundling of data and methods within a class, where the internal state of an object is protected from direct external access. It's like putting everything related to an object in a box and only allowing specific ways to interact with it from the outside. This helps keep code organized, secure, and easier to understand and modify.

Polymorphism:

"Polymorphism" comes from the Greek words "poly," meaning "many," and "morph," meaning "form" or "shape." In programming, polymorphism refers to the ability of objects to take on different forms or behaviors depending on the context in which they are used. This allows different objects to be treated interchangeably, enhancing flexibility and modularity in code design.

Advantages of OOP:

    1. Solves complex problems one step at a time for easier handling.
    2. Enhances software quality and lowers maintenance costs.
    3. Easily scales from small to large systems without major changes.
    4. Secures programs with data hiding to prevent unauthorized access.
    5. Reduces redundancy and extends code usability through inheritance.

Disadvantages of OOP:

    1. Complexity for beginners.
    2. Increased memory and processing overhead.
    3. Steeper learning curve.
    4. Potential for overdesign.
    5. Difficulty in debugging.
    6. Performance overhead.
    7. Not suitable for all applications.

Applications of OOP:

    1. Software development
    2. Graphical User Interface (GUI) development
    3. Database systems
    4. Simulation and modeling
    5. Embedded systems
    6. Artificial Intelligence and Machine Learning
    7. Financial systems
    8. Robotics

# Differences Between Object Oriented Programming (OOP) and Procedure Oriented Programming (POP)

Object-Oriented Programming (OOP)

Procedure-Oriented Programming (POP)

Organizes code around objects

Breaks down code into procedures

Combines data and functions into objects

Separates data and functions

Promotes code reusability through inheritance and composition

Achieves code reuse through function libraries

Encapsulates data and behavior within objects

Limited encapsulation, functions operate on external data

Supports inheritance for code reuse

Not a fundamental concept

Offers greater flexibility and adaptability

Generally less flexible

Java, C++, Python, C#

C, Pascal, Basic


No comments:

Post a Comment