Introduction to OOP
Introduction to OOP
Programming (OOP)
1st Event 2nd Event 3rd Event 4th Event 5th Event 6th Event
•Procedural Programming:
• Code is organized into functions or procedures
that can be called in a sequence.
• Data is typically global or passed as parameters
to functions.
• Reusability is achieved through function calls.
•Object-Oriented Programming (OOP):
• Code is organized into classes that encapsulate
both data (attributes) and behavior (methods).
• Objects of these classes interact by invoking
methods and exchanging messages.
• Reusability is achieved through class
inheritance and object composition.
Data Management
•Procedural Programming:
• Data is typically managed as separate
variables.
• Global data can lead to data integrity
issues.
• Access to data may not be controlled.
•Object-Oriented Programming (OOP):
• Data is encapsulated within objects, and
access is controlled through methods.
• Encapsulation enhances data security and
allows for controlled modification of data.
Reusability
•Procedural Programming:
• Reusability is achieved through function
calls.
• Code may need to be duplicated to use
similar functionality in different parts of
the program.
•Object-Oriented Programming (OOP):
• Reusability is achieved through class
inheritance and object composition.
• Code can be shared and extended more
easily, reducing redundancy.
Real-World Analogy
•Procedural Programming:
• Analogous to assembling a set of tools
and using them to perform specific
tasks.
• Emphasizes the procedures or steps
required to accomplish a task.
•Object-Oriented Programming (OOP):
• Analogous to designing objects that
encapsulate both the tools and the
procedures for accomplishing a task.
• Emphasizes modeling real-world entities
and their interactions.
When to Choose OOP
over Procedural
Programming
Deciding whether to use OOP or Procedural
Programming depends on the nature and complexity
of the project:
Use OOP when:
• You want to model real-world entities and their
relationships.
• The project is complex and benefits from
modularity and code organization.
• Code reuse and extensibility are important.
Use Procedural Programming when:
• The project is relatively simple and linear.
• The primary focus is on executing a series of steps.
• You have experience with the procedural paradigm
and the project doesn't require complex
interactions between components.
OOP vs. Procedural
Programming