Object Oriented Programming (OOP)
Object Oriented Programming (OOP)
1
Paradigms of Programming
• A programming paradigm is a :
• Style of programming.
• Way of representing concepts and abstraction
which are used to represent the elements of a
program and steps that compose a computation
• Common programming paradigms : Imperative :
• Procedural (Non-Structured) Programming
• Object Oriented Programming
• Some of the programming languages are designed to
support one paradigm and some of them support
multiple paradigms.
2
Procedural Programming
• Code is written in a single continuous program
• Lines may be numbered or labelled
• Allows control flow to jump to any line
• Leads to “spaghetti” code
• Program works on data directly
• An Example
• Basic programming language : C , Pascal
• Limitation
• Difficult to maintain code as size of program
increases
• Code cannot be reused
• Difficult to test code
3
Object Oriented Programming
• Paradigm for problem solving by interaction among objects
• This is a programming paradigm that deals with modeling
of real-world objects into a computer program.
• Real world objects have;
• Properties
• Exhibit behavior and interacts with other objects
• And State
• There are date objects, time objects, audio objects, video
objects, automobile objects, people objects, etc.
• Almost any noun can be reasonably represented as a
software object in terms of
• Attributes(e.g., name, color and size) – variables and
• Behaviors(e.g., calculating, moving and
communicating) – Methods.
4
Why OOP?
5
Programmation Language
• Object oriented programming (OOP) is facilitated by
languages that offer features for creating and
manipulating objects.
• Key languages supporting OOP include
• Java : SpringBoot
• Python
• C#: Dot. Net
• JavaScript: Angular
• Dart: Flutter
6
OOP……
7
Key object-oriented Concepts
8
Object
• Object is an instance of a class that holds data
(values) in its variables. Data can be accessed by its
functions
• Objects are fundamental runtime entities in object-
oriented systems, representing various entities such
as a person, a place, a bank account, or a table of
data.
• They encompass both physical and logical from Real
world object, each with its own identity, state, and
behavior, like a Pencil , apple ,Book , Bag Or Board
9
Methods and Classes
• Performing a task in a program requires a method.
• The method houses the program statements that
actually perform its tasks.
• The method hides these statements from its user,
• Just as the accelerator pedal of a car hides from
the driver the mechanisms of making the car go
faster.
• In OOP, we create a program unit called a class
• To house the set of methods that perform the
class’s tasks.
• A class is similar in concept to a Flower’s
engineering drawings, which house the design of
an accelerator pedal, steering wheel, and so on.
10
Encapsulation
11
Abstraction
• Extracting essential properties and behavior of
an entity
• Class represents such an abstraction and is
commonly referred to as an abstract data type
• Abstraction in object-oriented programming
hides complex implementation details from
users.
• It allows users to interact with objects based on
their functionality rather than their internal
workings.
• This concept is similar to how a car's pedals
abstract away the mechanics of acceleration
and braking.
12
Inheritance
• Inheritance is the process in object-oriented
programming where a class can acquire the
attributes and methods of another class, promoting
a hierarchical organization of information.
• This mechanism allows a subclass, also known as a
derived or child class, to inherit properties from a
superclass, referred to as a base or parent class.
• With inheritance, the subclass can access and
utilize the features of the superclass without
needing to redefine them, enhancing code
reusability and maintainability.
• Inheritance facilitates the addition of new
functionalities to existing classes without modifying
their original structure, thereby promoting
flexibility and scalability in software development.
13
Polymorphism
• Polymorphism, originating from Greek roots meaning
"many shapes," refers to entities in Java that can take
on multiple forms, such as operators, constructors, or
methods.
• This concept allows operations to exhibit different
behaviors depending on the type of data involved. For
instance, addition can yield a sum for numerical
operands, while concatenating strings.
• Polymorphism enables flexibility and versatility in
programming, as it allows operators to perform
distinct actions based on the context in which they are
used.
• In Java, polymorphism facilitates code reusability and
enhances the readability and maintainability of
programs by allowing methods to be defined more
generically, capable of handling various types of input.
14
Benefits of OOP
Modular programming
enables the creation of Data hiding enhances
OOP provides numerous Inheritance reduces code
programs using reusable program security by
advantages for both duplication and allows for the
modules, saving development preventing unauthorized
programmers and users: extension of existing classes.
time and enhancing access to sensitive data.
productivity.
Object mapping simplifies the Object based partitioning Data centered design captures Object oriented systems scale
representation of real world facilitates project organization model details effectively for seamlessly from small to large
entities in the program. and management. implementation. projects.
Testing Difficulty:
Misuse Potential: Improper Encapsulation Concerns: Performance Concerns:
use can result in code that's Encapsulation can be Testing can be challenging, May lead to performance
hard to maintain and broken, leading to especially with complex bottlenecks compared to
debug. unexpected behavior. hierarchies and other paradigms.
dependencies.
16
Application of OOP
Real world business systems tend to be intricate, featuring numerous
objects with intricate attributes and methods. OOP proves invaluable in
tackling such complexity, offering simplification for intricate problems.
Key domains where OOP finds promising application include:
Hypertext,
Simulation and Object oriented
Real time systems hypermedia, and
modeling databases
expertext
17
• Kairouan , Tunisie
• Higher Institute of Applied Mathematics and Computer Science
• For further information please contact
Email: najmejarray@gmail.com
18