OOP Lecture 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Introduction to Object

Oriented
Programming

Presented by Sheeza Shabbir


Table of content
Revision
Introduction
Why OOP?
Difference between Structured or procedural
and OOP
Revision
Procedural Programing
Welcome to the comprehensive
analysis of Procedural Programming
and OOP. This presentation aims to
unravel the paradigm duality and
provide insights into their strengths
and weaknesses.
Key Characteristics of
Procedural Programming:
Procedure-Centric: The primary
focus is on procedures or functions
that perform specific tasks.
Global Data: Data is often global
and shared among procedures.
Top-Down Execution: The program
follows a top-down flow of control,
starting from the main procedure.
Limited Code Reusability: Code
reuse is limited, and functions may
need to be adapted for different
contexts.
Drawbacks of Procedural
Programming:
Limited Code Reusability: Functions are often
designed for specific tasks, making it
challenging to reuse code for different
purposes.
Global Data: The use of global data can lead to
issues related to data integrity, and security,
and make it harder to trace the flow of data
through the program.
Difficulty in Managing Complexity: As
programs grow in size and complexity,
managing the flow of control and maintaining
a clear structure becomes challenging. This
can result in "spaghetti code," making it
difficult to understand and modify the code.
Introduction OOP
Object-Oriented Programming
(OOP) is a programming paradigm
that organizes software design
around the concept of "objects."
It is a way of writing computer
programs using the idea of "objects"
that encapsulate data and the
methods that operate on that data.
The primary goals of OOP are to
increase code reusability, improve
modularity, and enhance the clarity
and structure of code.
Modularity
Why OOP
Modularity:
.Benefits: Improved code organization,
maintenance, and the ability to update or
replace modules without affecting the
entire system.
Code Reusability:
Benefits: Reduced redundancy, increased
efficiency, and easier maintenance.
Flexibility and Extensibility:
Benefits: Systems can be easily adapted
or extended to meet changing
requirements, making the code more
flexible and accommodating future
enhancements.
Why OOP
Improved Understandability and Design:
Benefits: The design of software systems becomes
more intuitive and closely mirrors the problem
domain.
Enhanced Maintenance:
Benefits: Easier debugging, updating, and adding
new features without disrupting the entire system.
Support for Abstraction:

Benefits: Improved problem-solving by focusing


on essential aspects, reducing complexity, and
promoting a clearer understanding of the software.
Polymorphism:
Benefits: Code that can work with a variety of
objects, providing versatility and supporting a
broader range of use cases.
Comparison between OOP and Procedural Programming
1. Code Organization and Reusability
Procedural:
1. Strengths: Simple and straightforward for small-scale projects. Well-suited
for tasks with a linear flow.
2. Weaknesses: Limited code reuse, which can lead to redundancy and
maintenance challenges as the project grows.
OOP:
1. Strengths: Encourages code reuse through encapsulation, inheritance, and
polymorphism. Provides a modular and scalable structure.
2. Weaknesses: Can introduce some complexity for small projects.
Comparison between OOP and Procedural Programming
1. Code Organization and Reusability
Example:
Consider a banking system where you need to model customers, accounts, and
transactions. OOP is beneficial here because you can create classes like Customer,
Account, and Transaction, encapsulating their data and behaviors. Inheritance can
be used to model different types of accounts, and polymorphism allows for flexibility
in handling various transaction types.
Comparison between OOP and Procedural Programming
2. Maintenance and Extensibility:
Procedural:
1. Strengths: Can be more straightforward for small projects with less
complexity.
2. Weaknesses: May become challenging to maintain and extend as the project
grows, leading to spaghetti code.
OOP:
1. Strengths: Encourages a modular design, making it easier to maintain and
extend. Changes to one part of the system are less likely to affect others.
2. Weaknesses: Can introduce some overhead and complexity, especially for
simple tasks.
Comparison between OOP and Procedural Programming
2. Maintenance and Extensibility:

Example:
Consider an e-commerce platform where you need to handle different types of
products, payments, and shipping methods. OOP allows you to create modular
classes like Product, PaymentMethod, and ShippingMethod. When you need to
introduce new types of products or payment methods, you can extend existing
classes without modifying the entire system.
Comparison between OOP and Procedural Programming
3. Collaboration and Teamwork:
Procedural:
1. Strengths: Can be more straightforward for individual development or small
teams.
2. Weaknesses: This may lead to challenges in collaboration as the project scales,
especially when multiple developers are working on different functions.
OOP:
1. Strengths: Encourages a more natural representation of real-world entities,
making it easier for teams to collaborate. Code can be divided into classes, and
developers can work on different components simultaneously.
2. Weaknesses: Requires a good understanding of class relationships and
hierarchies, which may be challenging for some developers.
Comparison between OOP and Procedural Programming
3. Collaboration and Teamwork:
Example:
Imagine developing a video game where you have different characters, weapons,
and environments. OOP is advantageous here because each element can be
represented as a class (e.g., Character, Weapon, Environment). Different team
members can work on different aspects of the game without interfering with
each other's code.
Summary
Organizational Paradigm:
1. OOP: Objects and classes structure the code.
2. Procedural: Procedures and functions dictate code organization.
Code Reusability:
1. OOP: High reusability through features like inheritance and polymorphism.
2. Procedural: Limited code reusability; functions are task-specific.
Data Handling:
1. OOP: Emphasis on encapsulation for data security.
2. Procedural: Relies on global data, potentially impacting modularity.
Flexibility and Extensibility:
1. OOP: Flexibility via polymorphism; extensibility with inheritance.
2. Procedural: Flexibility through functions; extensibility may be more challenging.
Design Philosophy:
1. OOP: Holistic design based on essential properties and behaviors.
2. Procedural: Sequential design philosophy, organizing code into steps or tasks.
Question session??

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy