Object Oriented Programming
Md Shakil Siddique
Lecturer
Dept. of CSE, NMDC
Reference Books
1. Object-Oriented Programming with C++
Author: E. Balagurusamy
Publisher: McGraw-Hill
Edition: 4th / 7th (Global).
2. Teach Yourself C++
Author: Herbert Schildt
Publisher: McGraw-Hill
Edition: 3rd (Global).
3. Programming With C++
Author: John R. Hubbard
Publisher: Schaum’s Outline
Edition: 3rd (Global).
Introduction to Object Oriented Programming 2
Definitions
Computer Programming
The process of creating a set of instructions that tell a computer how to perform a task.
Computer Programming Techniques
1. Unstructured Programming
2. Modular/ Structured Programming
3. Procedural Programming
4. Object Oriented Programming
Introduction to Object Oriented Programming 3
Computer Programming Techniques
1. Unstructured Programming
The code is written as a single whole block.
The whole program is taken as a single unit.
Used in earlier versions of BASIC, COBOL,
Assembly, and FORTRAN.
Drawbacks
Program gets sufficiently long.
Limited number of data types
like numbers, arrays, strings.
Harder to do changes in the program.
Introduction to Object Oriented Programming 4
Computer Programming Techniques
2. Modular/ Structured Programming
The code is divided into functions or modules.
Easy for the programmer to test and debug.
Also easy to do modifications without changing the whole program.
C, Pascal are structured programming language.
*Modules or functions are a set of statements which performs a sub task.
Introduction to Object Oriented Programming 5
Difference Between Structured and Unstructured Programming
Introduction to Object Oriented Programming 6
Difference Between Structured and Unstructured Programming
Introduction to Object Oriented Programming 7
Computer Programming Techniques
3. Procedural Programming
Based upon the concept of calling procedure.
Derived from structured programming.
Revolves around a sequence of instructions given to the computer i.e. Procedure.
Follows top-down approach as the instructions are carried out in well-defined sequences.
Instructions are divided into smaller blocks of well-defined code called Function. Each
function performs a specific task.
Procedural program involves calling the right function at the right time, i.e., using the
appropriate function at the appropriate place within the larger code.
Data and Functions (Procedure) treated as separate in procedural programming.
*Procedures, also known as routines, subroutines or functions, simply consist of a series of computational steps to
be carried out.
Introduction to Object Oriented Programming 8
Computer Programming Techniques
3. Procedural Programming
Introduction to Object Oriented Programming 9
Computer Programming Techniques
3. Procedural Programming
Functions are called repeatedly in a program to execute tasks performed
by them.
For example,
A program may involve collecting data from user (reading), performing
some kind of calculations on the collected data (calculation), and finally
displaying the result to the user when requested (printing). All the 3
tasks of reading, calculating and printing can be written in a program
with the help of 3 different functions which performs these 3 different
tasks.
Introduction to Object Oriented Programming 10
Computer Programming Techniques
3. Procedural Programming
Features
• Predefined functions
• Local Variable
• Global Variable
• Modularity: This is the practice of using different functions and procedures simultaneously to
accomplish a single, greater task. Each procedure performs a specific task that is different from
other functions. But combining their results leads to accomplishing the greater task.
• Parameter Passing: Parameter Passing is a mechanism used to pass parameters to functions,
subroutines or procedures. Parameter Passing can be done through ‘pass by value’, ‘pass by
reference’, ‘pass by result’, ‘pass by value-result’ and ‘pass by the name’.
Introduction to Object Oriented Programming 11
Computer Programming Techniques
3. Procedural Programming
Benefits
• Simplicity: Procedural programming is easy to understand and code due to its simple structure.
• Reusable Code: Functions can be reused within the program again and again. This makes coding
easier. It also reduces the length of the code and the time needed to write the entire program.
• Easy Testability: The simplicity of procedural programming makes the code easy to test and debug.
The shorter program length and the use of reusable code are great for quickly identifying sources of
errors.
• General Programming: The procedural paradigm is great for general use and for smaller projects.
• Smaller Memory Requirement: Procedural programming utilizes less memory than other paradigms.
This increases the efficiency of our program.
• Team-Friendly: Multiple programmers can work on the same project simultaneously, with each
programmer coding a different function. These functions can then be combined into a single project.
• Accessibility: There are a lot of resources available to learn procedural programming since it is often
the first paradigm that is taught to beginners.
Introduction to Object Oriented Programming 12
Computer Programming Techniques
3. Procedural Programming
Drawbacks
• Focused on Operations: Procedural programming focuses on functions and procedures more than
data. This method is unsuitable for projects where data is important.
• No Data Security: Data is exposed and accessible to multiple procedures in procedural programming.
Thus, it is unsuitable for projects where we must protect data.
• No Portability: With procedural programming, code can be reused within a single project. However,
they cannot be exported to other projects. So we need to rewrite a lot of code when working on other
projects.
• Cannot Model the Real World: Since procedures are prioritized over data and objects, this paradigm
cannot model the real world properly.
• Unsuitable for Complexity: Procedural programming is unsuitable for creating large-scale and
complex applications.
Usage: Creating compilers, operating systems, kernels, embedded systems, code server-side applications etc.
Introduction to Object Oriented Programming 13
Computer Programming Techniques
4. Object Oriented Programming
A computer programming design philosophy or methodology that models software
design around data, or objects rather than functions and logic.
Well suited for programs that are large, complex, and actively updated or
maintained.
Certain process through which software can be developed.
Divided into Classes and Objects.
Goals
To achieve Software Systems that are reliable,
reusable, extensible; hence, more useful in the
long run.
The methodology achieves its goals by the help of a
collection of objects that communicate by
exchanging messages.
Introduction to Object Oriented Programming 14
Computer Programming Techniques
4. Object Oriented Programming
What is Object-Orientation?
• A technique for system modeling.
• Object Oriented model consists of several interacting objects.
What is a Model?
• A model is an abstraction of something .
• Purpose is to understand the product before
developing it.
• Example: Library Management System, Hospital
Management System, Highway Maps,
Architectural Models etc.
Why we use OOM?
• People think in terms of objects.
• OO models map to reality.
• Therefore, OO models are easy to develop and
easy to understand. Introduction to Object Oriented Programming 15
Computer Programming Techniques
4. Object Oriented Programming
Introduction to Object Oriented Programming 16
Computer Programming Techniques
4. Object Oriented Programming
Advantages of Object Oriented Programming
• Objects are modeled on real world entities.
• This enables modeling complex systems of real world into manageable software solutions.
Advantage of OOPS
• It provides data hiding
• It provides data encapsulation
• It provides data abstraction
• It provides reusability of code
• It provides easy code maintenance
Introduction to Object Oriented Programming 17
Computer Programming Techniques
Introduction to Object Oriented Programming 18
Computer Programming Techniques
Introduction to Object Oriented Programming 19
Computer Programming Techniques
Introduction to Object Oriented Programming 20
Procedural vs OOP concepts
Introduction to Object Oriented Programming 21
Procedural vs OOP concepts
Introduction to Object Oriented Programming 22
Procedural vs OOP concepts
Introduction to Object Oriented Programming 23
Procedural vs OOP concepts
Introduction to Object Oriented Programming 24
Procedural vs OOP concepts
Introduction to Object Oriented Programming 25
Procedural vs OOP concepts
Introduction to Object Oriented Programming 26
Procedural vs OOP concepts
Introduction to Object Oriented Programming 27
QnA
Software Design Fundamental 28
Software Design Fundamental 29