Object Oriented Programming
[FECEg-3142]
CHAPTER ONE:
Introduction to the OOP
paradigm
Outline
Introduction
Comparison between procedural/ structured
programming and OOP.
Basic concepts: abstraction, encapsulation,
information hiding.
Program reusability and extensibility.
Introduction
What is programing ?
Program- Sequence of instructions
3
Cont’d...
How our program work on Digital
machine
4
Cont’d...
Why Programming
5
Cont’d...
Programing Language
Machine languages
Assembly languages
High‐level languages
6
Cont’d...
Steps for writing a Program
Step 1: Statement of the problem
Step 2: Input/ output description (Data)
Step 3: Algorithm development – Sequence of step
Step 4: Coding
Step 5: Testing
7
Cont’d...
What is a benefit to be a
programmer
Positive Social impact.
Being a creator
Job Satisfaction
8
Comparison between procedural/
structured programming and OOP
There arc two common programming approach:
procedural programming and
object-oriented programming (or OOP)
9
Cont’d...
Procedural programming is a programming
practice centered on the procedures or actions
that take place in a program.
Object-oriented programming is centered
around the object. Objects are created from
abstract data types that encapsulate data and
functions together.
10
Procedural vs. Object-Oriented
Programming
In procedural programming the data and the
functions are separate entities.
When programs become larger and more
complex, the separation of a program's data
and the code that operates on the data can lead
to problems.
11
Cont’d...
MAIN PROGRAM GLOBAL DATA
FUNCTION FUNCTION 2 FUNCTION 3
1
FUNCTION 4 FUNCTION 5
12
Cont’d...
When the structure of the data changes, the
code that operates on the data must also
change to accept the new format.
This results in additional work for
programmers and a greater opportunity
for bugs to appear in the code.
This problem has helped influence the
shift from procedural programming to
object-oriented programming.
13
Cont’d...
Whereas procedural programming is
centered on creating procedures or functions,
object-oriented programming is centered on
creating objects.
An object is a software entity that contains
both data and procedures.
The object is, conceptually, a self-contained
unit consisting of attributes (data) and
procedures (functions).
14
Cont’d...
OOP addresses the problems that can result from the
separation of code and data through encapsulation
and data hiding.
Encapsulation refers to the combining of data and
code into a single object.
Data hiding refers to an object's ability to hide its
data from code that is outside the object.
15
Basic concepts:
Abstraction
Encapsulation or information hiding
16
Abstraction
Abstraction refers to the act of representing
essential features without including the background
details or explanations.
Example We can Driving a car with out knowing
how each system work
We can use object without knowing its internal
implementation.
17
Encapsulation
Encapsulation: wrapping up of data and
methods into a single unit (called class)
Data is not accessible to the outside world and
only those methods in the class can access it
insulation of the data from direct access by a
program is called data hiding
18
Inheritance
is a process by which object of one class acquire
the property of object of other class
Classes with properties in common can be
grouped so that their common properties are only
defined once
Superclass – inherit its attributes & methods to
the subclass(es).
Subclass – can inherit all its superclass attributes
& methods besides having its own unique
attributes & methods.
19
Cont’d...
Superclass
Vehicle
Subclasses
Automobile Motorcycle Bus
Sedan Sports Car Luxury Bus School Bus
20
Polymorphism
The ability to take more than one form
The same word or phrase can mean different
things in different contexts
Analogy:
In English, bank can mean side of a river or a
place to put money
21
Program reusability and extensibility
Re-usability – without redundant code
Sharing a certain code within a program
Previously written code can be used again
in the new code.
Extensible – possible to alter additional features
to the existing class.
22
End
23