1 - Evolution of OOP Week 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

Rohail Qamar

OBJECT ORIENTED PROGRAMMING Lecturer, CS&IT


EVOLUTION OF OOP rohailqamar@neduet.edu.pk
COURSE LECTURER
 Rohail Qamar : rohailqamar@neduet.edu.pk

 Teaching Experience : NED University, HU, NHU, Aptech

 Ph.D. Scholar

 MS-DEIM NED University of Engineering & Technology

 Masters’ Thesis: Title: “Flight Traffic Collision Avoidance System Using Data Analytics”

 BSCS: UIT (Hamdard University) [ALHAMDULILLAH Gold Medallist]

 Research: Data Analytics, Machine Learning, Deep Learning and Digital Image Processing

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


COURSE LEARNING OBJECTIVES

1. Recognize the principles of object-oriented paradigm

2. Comprehend the objects & their relationships to build an object-


oriented solution.

3. Implement an object-oriented solution for a given case study.


(FOR LABORATORY WORK)

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


TEXTBOOK
Object Oriented Programming in C++, 3rd Edition by Robert Lafore

Starting Out with C++ from Control Structures to Objects 9th Edition

Reference Book

Design Patterns Explained: A New Perspective on Object


Oriented Design by Allan Shalloway and James R Trott

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


WEIGHT OF ASSESSMENTS
Midterm examination 20%
Final term examination 60%
Quizzes 10%
Presentation 10%
Total 100%

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


SYLLABUS
Evolution of OOP
Pillars of OOP
Encapsulation
Inheritance
Polymorphism
Abstraction
UML Class Diagram

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


TOOLS & IDE
Anaconda (Python)

VS Code (C++)

Dev C/C++

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


TOPICS TO BE COVERED
Procedural Programming and Structural Programming

Introduction to object oriented design, Need of Object Oriented


Programming

Real-World Modeling: Object-Oriented Approach

Characteristics of Object Oriented Programming

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


INTRODUCTION TO OO DESIGN
NEED OF OOP

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


OBJECT ORIENTED DESIGN
A new way of thinking to design solution to your problem

Facilitates easy and efficient maintenance in case of any change in the


system’s requirement

More advance concepts leads towards learning ‘design patterns’ in parallel


with object-oriented design.

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


NEED OF OBJECT ORIENTED PROGRAMMING
Object-oriented programming was developed because limitations
were discovered in earlier approaches to programming.

Traditional programming languages have limitations. These


languages are categorized into:
 Procedural Languages
 Structural programming languages

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


WHAT IS PROCEDURAL PROGRAMMING
LANGUAGE
Initially, a small program in a procedural language was list of
instructions.

Instructions in these languages follows a sequence and allows repetition


in some steps.

Problem arise when errors need to be identified and corrected.

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


WHAT IS PROCEDURAL PROGRAMMING
LANGUAGE
These languages are suitable for writing small programs. When programs
become larger, a single list of instructions becomes complex.

To tackle this problem, the function was adopted as a way to make programs
more comprehensible to their human creators.

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


WHAT IS PROCEDURAL PROGRAMMING
LANGUAGE
C, Pascal, FORTRAN, and similar languages are procedural languages.

The term function is used in C++ and C. In other languages the same concept
may be referred to as a subroutine, a subprogram, or a procedure.

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


WHAT IS PROCEDURAL PROGRAMMING
LANGUAGE
A procedural program is divided into functions, and (ideally, at least) each function
has a clearly defined purpose and a clearly defined interface to the other functions
in the program.

The idea of breaking a program into functions can be further extended by grouping
a number of functions together into a larger entity called a module

Dividing a program into functions and modules is one of the cornerstones


(features) of structured programming

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


WHAT IS PROCEDURAL PROGRAMMING
LANGUAGE
A function is a group of statements that exist within a program for the
purpose of performing a specific task
In object oriented programming it is known as Method
Instead of writing a large program as one long sequence of statements, it
can be written as several small functions, each one performing a specific part
of the task
This approach is sometimes called divide and conquer because a large task is
divided into several smaller tasks that are easily performed
A program that has been written with each task in its own function is called a
modularized program

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


WHAT IS PROCEDURAL PROGRAMMING
LANGUAGE

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


WHAT IS PROCEDURAL PROGRAMMING
LANGUAGE

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


WHAT IS PROCEDURAL PROGRAMMING
LANGUAGE

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


SYNTAX OF A METHOD WITH NO RETURN TYPE
AND NO PARAMETERS
1 2

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


SYNTAX OF A METHOD WITH NO RETURN TYPE
AND PARAMETERS 1
2

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


SYNTAX OF A METHOD WITH RETURN TYPE AND
NO PARAMETERS
1 2

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


SYNTAX OF A METHOD WITH RETURN TYPE AND
PARAMETERS 1
2

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


BENEFITS OF MODULARIZING A PROGRAM WITH
FUNCTIONS
Simpler Code
A program’s code tends to be simpler and easier to understand when it is
broken down into functions.

Several small functions are much easier to read than one long sequence of
statements.

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


BENEFITS OF MODULARIZING A PROGRAM WITH
FUNCTIONS
Code Reuse
Functions also reduce the duplication of code within a program.
If a specific operation is performed in several places in a program, a
function can be written once to perform that operation, then be executed
any time it is needed.
This benefit of using functions is known as code reuse because you are
writing the code to perform a task once, then reusing it each time you need
to perform the task.

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


BENEFITS OF MODULARIZING A PROGRAM WITH
FUNCTIONS
Better Testing
When each task within a program is contained in its own function, testing
and debugging becomes simpler.

Programmers can test each function in a program individually, to


determine whether it correctly performs its operation. This makes it easier
to isolate and fix errors.

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


BENEFITS OF MODULARIZING A PROGRAM WITH
FUNCTIONS
Faster Development
Suppose a programmer or a team of programmers is developing multiple
programs.
They discover that each of the programs perform several common tasks,
such as asking for a username and a password, displaying the current time,
and so on.
Functions can be written for the commonly needed tasks, and those
functions can be incorporated into each program that needs them.
OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR
BENEFITS OF MODULARIZING A PROGRAM WITH
FUNCTIONS
Easier Facilitation of Teamwork
Functions also make it easier for programmers to work in teams.

When a program is developed as a set of functions that each performs an


individual task, then different programmers can be assigned the job of
writing different functions.

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


CLASS ACTIVITY
Write a program that take user input a number and pass the value to the function to
find whether its even or odd?
Write a program that take user input a year and pass the value to the function to
find whether its leap year or not?
Write a program that take user input a number and pass the value to the function to
find its factorial, return the result and display.
Write a program that take user input a number and its raised power pass them to
the function, return the result and display.

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


PROBLEMS WITH STRUCTURAL LANGUAGES
1. What are the reasons for these problems with procedural languages ?
a) Functions have unrestricted access to global data.
b) Second, unrelated functions and data, the basis of the procedural
paradigm, provide a poor model of the real world.
c) No matter how well the structured programming approach is implemented,
large programs become excessively complex.

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR


THANK YOU

OBJECT ORIENTED PROGRAMMING BY ROHAIL QAMAR

You might also like