Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 15

15CSE202 Object oriented Programming

15CSE202 Object Oriented Programming


Lecture 1

Overview of different programming paradigms


and problems in procedural paradigm

Nalinadevi Kadiresan
CSE Dept.
Amrita School of Engg.
15CSE202 Object oriented Programming 2

Evolution of Programming
Languages
•A computer language is a
set of predefined words that
are combined into a
program according to
predefined rules (syntax).
•Over the years, computer
languages have evolved
from machine language to
high-level languages.
June 2019 Nalinadevi Kadiresan
15CSE202 Object oriented Programming 3

June 2019 Nalinadevi Kadiresan


15CSE202 Object oriented Programming 4

Evolution of Programming
Languages - Paradigm
•Today, computer
languages are categorized
according to the approach
they use to solve a
problem.
•A paradigm, therefore, is a
way in which a computer
language looks at the
problem to be solved.
June 2019 Nalinadevi Kadiresan
15CSE202 Object oriented Programming 5

Evolution of Programming
Languages -contd
•We divide computer languages into four paradigms:
procedural, object-oriented, functional and logical.

June 2019 Nalinadevi Kadiresan


15CSE202 Object oriented Programming 6

Evolution of Programming
Languages -contd

June 2019 Nalinadevi Kadiresan


15CSE202 Object oriented Programming 7

Why do we move from


procedural to object-oriented
paradigm?

June 2019 Nalinadevi Kadiresan


15CSE202 Object oriented Programming 8

Problems with Procedural Languages -1


Functions are the building blocks.
Many functions can modify a given block of data.

Function 1
Function 3

DATA

Function 2
June 2019 Nalinadevi Kadiresan
15CSE202 Object oriented Programming 9

Problems with Procedural Languages -2

 Uninitialized variables.

int k ;
printf(“%d”,k) ;

Data does not have an owner.

June 2019 Nalinadevi Kadiresan


15CSE202 Object oriented Programming 10

Problems with Procedural Languages -3


 Resource Deallocation Problems
Examples: Memory leaks, open files, open database
connections, open network connections.
int* kp;
kp = (int*) malloc(1000);
kp = (int*) malloc(1000);
kp = (int*) malloc(1000);
Data does not have an owner.
 Difficult to pinpoint bug sources when data corrupted

June 2019 Nalinadevi Kadiresan


15CSE202 Object oriented Programming 11

Problems with Procedural Languages -4

Insufficient support for abstraction


ADT = data + functions
data: modelled as structures
functions: global, not related to structure

Data does not have an owner.


 Difficult to maintain data integrity.
June 2019 Nalinadevi Kadiresan
15CSE202 Object oriented Programming 12

Problems with Procedural Languages -4


struct stack struct queue
{ int top; { int front;
char* store;} ; int rear;
char* store;} ;
push(); insert();

pop(); delete();

All functions are global!!


June 2019 Nalinadevi Kadiresan
15CSE202 Object oriented Programming 13

Problems with Procedural Languages - 4

struct horse struct eagle


{weight, color, { age, weight
Age;}; wingspan;} ;

gallop(); fly();

canter(); hunt();

All functions are global!!


June 2019 Nalinadevi Kadiresan
15CSE202 Object oriented Programming 14

Problems with Procedural Languages


Summary
 Data does not have an owner.
 Difficult to maintain data integrity.
 Functions are the building blocks.
 Many functions can modify a given
block of data.
 Difficult to pinpoint bug sources when
data corrupted.
June 2019 Nalinadevi Kadiresan
15CSE202 Object oriented Programming 15

Next Session will be


OO Concepts

June 2019 Nalinadevi Kadiresan

You might also like