Programming and Problem Solving Lecture - 3-Introduction To Object Oriented Programming Programming Paradigm
Programming and Problem Solving Lecture - 3-Introduction To Object Oriented Programming Programming Paradigm
Prepared By :
Pallavi S Joshi
PROGRAMMING PARADIGMS
Introduction
To comprehend how languages are constructed, one needs to look in to more details.
The four basic computational models that describe most programming today are :
1) Imperative or procedural Language
2) Applicative or functional Language
3) Rule based or logic Language
4) Object oriented Language
5) Monolithic
6) Structured
Monolithic Programming
Programs written using monolithic programming languages such as assembly
language and BASIC consist of global data and sequential code. The global data
can be accessed and modified (knowingly or mistakenly) from any part of the
program, thereby, posing a serious threat to its integrity.
Monolithic programs have just one program module as such programming
languages do not support the concept of subroutines. Therefore, all the actions
required to complete a particular task are embedded within the same
application itself. This not only makes the size of the program large but also
makes it difficult to debug and maintain.
Procedural Programming
In procedural languages, a program is divided into n number of subroutines that access
global data. To avoid repetition of code, each subroutine performs a well-defined task. A
subroutine that needs the service provided by another subroutine can call that subroutine.
Therefore, with ‘jump’, ‘Go To’, and ‘call’ instructions, the sequence of execution of
instructions can be altered.
Advantages
• The only goal is to write correct programs.
• Programs were easier to write as compared to monolithic programming.
Disadvantages
• Writing programs is complex.
• No concept of reusability.
• Requires more time and effort to write programs.
• Programs are difficult to maintain.
• Global data is shared and therefore may get altered (mistakenly).
Structured Programming
Structured programming, also referred to as modular programming.
Advantages
Efficient, correct programs that are easy to understand, debug and change.
• Modules enhance programmer’s productivity.
Many programmers can work on a single, large program
• A structured program takes less time to be written than other programs. • Each module
performs a specific task.
• Each module has its own local data.
First to introduce the concept of functional abstraction.
Disadvantages
• Not data-centered.
• Global data is shared and therefore may get inadvertently modified.
• Main focus on functions.
Object Oriented Programming (OOP)
The major motivating factor in the invention of object-oriented approach is to remove some of the flaws
encountered in the procedural approach.
OOP treats data as a critical element in the program development and does not allow it to flow freely around the
systems.
It ties data more closely to the functions that operate on it, and protects it from accidental modification from
outside functions.
OOP allows decomposition of a problem into a number of entities called objects and then builds data and functions
around these objects.
The data of an object can be accessed only by the function associated with that object.
However, functions of one object can access the the functions of other objects.
11
Some of the striking features of object-oriented programming are
•Data structures are designed such that they characterize the objects.