0% found this document useful (0 votes)
22 views

Introduction to OOP

Uploaded by

joabjoshuajr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Introduction to OOP

Uploaded by

joabjoshuajr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Object-Oriented

Programming (OOP)

Mr. Joab Mumbere MCA (Amity), BIS (Mak).


jmumbere@newgateuniversityminna.edu.n
g
+256703729371 (WhatsApp).
Inheritance and
Polymorphism in Java

Definition of Object-Oriented Programming


(OOP)
• Object-Oriented Programming, often abbreviated as
OOP, is a programming paradigm that focuses on
organizing code into reusable and self-contained
objects. In OOP, these objects are instances of
classes, which act as blueprints defining their
structure and behavior. The primary goal of OOP is
to create more modular, maintainable, and efficient
code by modeling real-world entities and their
interactions.
Historical Context: Evolution of
Programming Paradigms

To appreciate the significance of OOP, it's


essential to understand its historical
context. Programming paradigms have
evolved over the years, each with its own
approach to solving problems:
Historical Context:
Evolution of Programming
•Paradigms
Procedural Programming: Early programming
centered around procedures or functions that
manipulate data. This paradigm lacked a clear
way to bundle data and functions together,
leading to challenges in code organization and
reuse.
Structured Programming: Introduced the
concept of control structures and emphasized
code organization through functions and
procedures.
Object-Oriented Programming (OOP):
Emerged as a response to the limitations of
procedural and structured programming. OOP
introduced a new way of thinking about code
organization based on objects.
Why OOP? The Motivation
Behind OOP

OOP addresses several key challenges that


developers faced with procedural
programming:
Why OOP? The Motivation
Behind OOP
•Complexity Management: In large projects,
procedural code can become unwieldy, making it
hard to understand and maintain. OOP helps
manage complexity by breaking code into smaller,
more manageable units (objects).
•Reusability: OOP promotes code reusability. Once
you've defined a class (a blueprint for objects), you
can create multiple instances (objects) of that class.
This reusability reduces redundancy and saves
development time.
•Abstraction: OOP allows developers to abstract
away unnecessary details, focusing on what an
object does rather than how it does it. This
abstraction simplifies problem-solving and makes
code more intuitive.
Advantages and Benefits of
Using OOP in Software
Development

OOP offers several advantages and


benefits to software developers and
organizations:
Advantages and Benefits
of Using OOP in Software
Development
•Modularity: Code is organized into self-
contained objects, making it easier to
understand and maintain.
•Reusability: Reusing classes and objects
reduces development time and minimizes errors.
•Encapsulation: Data is hidden within objects,
and access is controlled through methods,
enhancing data security and integrity.
•Flexibility: OOP supports inheritance and
polymorphism, allowing for flexible and
extensible code.
In Summary
• Object-Oriented Programming is a
programming paradigm designed
to address the shortcomings of
earlier paradigms by focusing on
modularity, reusability, abstraction,
and encapsulation. Understanding
the history and motivation behind
OOP sets the stage for delving
deeper into its core concepts.
History
Make a timeline of the important historical events or list historical contributions made by
people of Hispanic/Latino heritage.

1st Event 2nd Event 3rd Event 4th Event 5th Event 6th Event

Date Date Date Date Date Date

Description Description Description Description Description Description


Core Concepts of OOP
In our previous slides, we introduced the
fundamentals of Object-Oriented
Programming (OOP) and discussed why
OOP is essential in modern software
development. In this lecture, we will dive
deeper into the core concepts that
underpin OOP: classes, objects,
attributes, and methods.
Classes and Objects
At the heart of OOP are two fundamental concepts:
classes and objects. These concepts form the basis
of OOP and allow us to structure our code in a more
organized and reusable way.
• Class: A class is a blueprint or template for
creating objects. It defines the structure
(attributes or properties) and behavior (methods
or functions) that objects of that class will have.
Think of a class as a blueprint for a specific type of
object, like a "Car" class for creating car objects.
• Object: An object is an instance of a class. It is a
concrete realization of the class's blueprint, with
its own unique data stored in attributes. Objects
can interact with each other and invoke methods
defined in their class. For example, you can have
multiple "Car" objects, each with its own make,
model, and year.
Attributes
(Properties)
Attributes, also known as properties or
fields, are variables that store data within
an object. Attributes represent the state of
an object. For instance, if you have a
"Person" class, attributes might include
name, age, and address. Attributes give
objects their characteristics.
In code, attributes are defined within a
class and are specific to objects created
from that class. Access to attributes can
be controlled using access modifiers such
as public, private, or protected.
Methods (Functions)
Methods, also referred to as member
functions, are functions defined within a
class that perform operations on the
object's attributes or provide functionality
associated with the class. Methods are
what make objects of a particular class
useful. For example, a "Car" class might
have methods like "start_engine()" and
"accelerate()" that define how a car
functions.
Methods are called on objects and can
modify the object's state or perform
specific actions. They encapsulate
behavior within the class.
The Role of Objects, Classes,
Attributes, and Methods
Understanding how objects, classes, attributes,
and methods interact is crucial in OOP:
• Classes define the structure (attributes) and
behavior (methods) that objects will have.
• Objects are instances of classes, each with its
own unique attribute values.
• Attributes store the state of objects and
describe their characteristics.
• Methods define what objects of the class can
do and encapsulate their behavior.
By organizing code into classes and objects, we
create modular and reusable components that
mirror real-world entities and interactions,
making software development more efficient and
maintainable.
OOP vs. Procedural
Programming
In our previous lectures, we discussed the
foundational concepts of Object-Oriented
Programming (OOP). Now, it's time to explore how
OOP differs from Procedural Programming, another
prevalent programming paradigm. Understanding
these differences will help you make informed
decisions when choosing the right approach for
your software projects.
Comparison of OOP
and Procedural
Programming
OOP and Procedural Programming
are two distinct programming
paradigms, each with its own
approach to solving problems.
Let's compare these paradigms in
various aspects:
Approach to Problem-
Solving
• Procedural Programming:
• Focuses on procedures or functions that manipulate
data.
• Code is typically structured around functions that
take inputs, perform computations, and produce
outputs.
• Data and functions are separate, leading to a more
linear and step-by-step approach to problem-solving.
• Object-Oriented Programming (OOP):
• Centers around objects, which combine data
(attributes) and behavior (methods).
• Models real-world entities and their interactions.
• Encourages a more modular and intuitive approach,
where objects interact by sending messages to each
other.
Code Organization

•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

Understanding the differences


between these paradigms will help
you choose the most appropriate
approach for your programming
tasks, ensuring that your code is
structured and organized effectively.
Questions!
Any Question ?
Resources
List the resources you used for your
research:
• Object-Oriented Software Engineering: Practical
Software Development Using UML and Java" by
Timothy C. Lethbridge and Robert Laganière.
• "Head First Java" by Kathy Sierra and Bert Bates (For
a Java-focused course).

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