OOP File 01
OOP File 01
SLIDE 1
2
Course Objective
3
Books
5
Programming Paradigm
► Procedural (Structure-oriented )
► Object-Oriented Programming
► Functional
► Logic
► Scripting
6
Procedural Concept
The problem (to be solved) is viewed as a sequence of things
(operation) to be done.
Operations (actions/instructions/commands) may be reading,
calculating, printing etc.
Use flowchart to organize these actions
A function (Procedure) is written to accomplish the operations
A list of instructions/commands is in a function
Thus primary focus on functions
So, it’s also called structure-oriented, action-oriented,
instruction-oriented. 6
Procedural Concept
Hierarchical decomposition of functions
Main program
Data
Function 1 Function 2
Function 6 Function 7
► The main program coordinates calls to procedures and hands over
appropriate data as parameters.
7
Procedural Concept
Relationship of data and functions:
— What happens to the data? Data move openly around the system from function to
function
— How are they affected by the functions? Data are transformed by the functions
from one form to another.
10
Pre-discussion for OOP
Structure:
– For example:
struct students
{
char name[50];
char address[100];
char dept_faculty[20];
int level;
char semester[3];
int session;
float CGPA;
} student[100];
Structure variable is not like built-in types: student[1]=student[2]+student[3];
impossible
Do not permit functions and data hiding in it.
11
Pre-discussion for OOP
12
What is Object-Orientation?
13
What is a Model?
14
Example of Objects for OO Model
15
Example – OO Model
lives-in
Ali House
> Objects
— Ali drives
— House
— Car
— A book Car Tree
— A student
— Tree
> Interactions
— Ali lives in the house
— Ali drives the car
16
Object-Orientation - Advantages
17
What is an Object?
18
What is an Object?
An object has:
Unique identity
19
Example – Ali is a Tangible Object
20
Example – Car is a Tangible Object
21
Example – Time is an Object Apprehended
Intellectually
22
Example – Date is an Object Apprehended
Intellectually
23
OO Programming Concepts
Object 1 Object 2
Data Data
Communication
Functions Functions
Object 3
Data
Functions
26
Object-Oriented Programming
27