Procedure-Oriented Programming
vs
Object Oriented Programming
Programming Language : Definition
A vocabulary and set of grammatical rules for
instructing a computer to perform specific tasks.
Programming Languages
Programmer use Programming languages to develop the
software.
The three major families of languages are:
oMachine languages
oAssembly languages
oHigh-Level languages
Machine Languages
Comprised of 1s and 0s
The “native” language of a computer
Difficult to program – one misplaced 1 or 0 will cause the
program to fail.
Example of code:
1110100010101 111010101110
Assembly Languages
Assembly languages are a step towards easier programming.
Assembly languages are comprised of a set of elemental
commands. (MNEMONICS)
Assembly language code needs to be translated to machine
language before the computer processes it.
Example:
LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
High-Level Languages
High-level languages represent a giant leap towards
easier programming. The syntax of HL languages is
similar to English.
Historically, we divide HL languages into two
groups:
Procedural Oriented Programming
Object-Oriented Programming (OOP)
Procedure-Oriented Programming
Large programs are divided into Smaller Programs know as function.
Most of the functions share global data.
Data move openly around the system from function to function.
Top-down approach in program design.
Object -Oriented Programming
Striking feature
Programs are divided into what are known as objects.
Data is hidden and cannot be accessed by external functions.
Program can be easily extend whenever necessary.
Bottom-up approach in program design.
 Structured programming enable programmers
to write moderately complex programs fairly
easily.
 However as the programs grew larger, even the
structured approach failed to show the desired
results in terms of bug-free, easy-to-maintain
and reusable programs.
 Object-Oriented Programming (OOP) is an
appraoch to program organization and
development that attempts to elimate some of
the pitfalls of conventional programming
methods by incorporating the best of structured
programming features with several powerful
new concepts.
Procedure-Oriented Programming
 Conventional programming using high level
language such as COBOL, FORTRAN and C is
commonly known as Procedure-oriented
programming.
 In the Procedure-oriented approach the
problem is viewed as a sequence of things to
be done.
 The primary focus is on functions.
Structure of Procedure-oriented
Main Program
Function 1 Function 2 Function 3
Function 5
Function 4
Procedure-Oriented Programming
 Procudure-oriented programming basically
consists of writing a list of instructions for the
computer to follow and organizing these
instructions into groups known as functions.
Structure of Procedure-oriented
Global data
Function 2
Global data
Function 3
Function 1
Local data Local data Local data
Procedure-Oriented Programming
 What happens to data? How are they affected
by the functions that work on them?
 In multi-function program many important data
items are placed as global so that they may be
accessed by all the functions.Each function may
have its own local data.
 In large program it is very difficult to identify
what data is used by which function. In case we
need to revise an external data structure we
also need to revise all function that access it.
Object-Oriented Programming
 OOP treats data as a critical element in the
program development and does not allow it to
flow freely around the system.
 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 entites called objects.
Organization of data & function OOP
Data
Functions
Data
Functions
Data
Functions
Object C
ObjectA Object B
Basic concepts of OOP
 Objects
 Class
 Data Abstration
 Encapsulation
 Inheritance
 Polyomorphism
 Dynamic binding
 Message Passing
The three pillars of object-oriented development:
 Encapsulation, Inheritance, and Polymorphism.
Object
Object is a real world entity, for example, chair, car, pen, mobile,
laptop etc.
In other words, object is an entity that has state and behavior.
Here, state means data and behavior means functionality.
Object is a runtime entity, it is created at runtime.
Object is an instance of a class. All the members of the class can
be accessed through object.
Let's see an example to create object of student class using
s1 as the reference variable.
Student s1; //creating an object of Student
Object Example
Object and Class
Class
Class is a model for creating objects.
A class is the building block, that leads to Object-Oriented
programming.
A class is thus a collection of objects of similar types.
 It is a user-defined data type, which holds its own data members and
member functions, which can be accessed and used by creating an
instance of that class.
A class is like a blueprint for an object or blueprint for
creating objects (a particular data structure), providing initial values for
state (member variables or attributes), and implementations of behavior
(member functions or methods).
Class
Class is a template from which objects are created. It can have
fields, methods.
The user-defined objects are created using the class keyword.
 The class is a blueprint that defines a nature of a future object.
An instance is a specific object created from a particular
class. Classes are used to create and manage new objects and
support inheritance—a key ingredient in object-oriented
programming and a mechanism of reusing code
Classes
 Once a class has been defined we can create any
number of objects belonging to that class.
Classes
 Fruit is a class defined as a Class.
 fruit f1;
 Here fruit is Class.
 And f1 is an object of fruit Class.
Encapsulation
 The wrapping up of data and functions into a single
unit is known as Encapsulation
 The data is not accessible to the outside world and
only those functions which are wrapped in the class
can access it.
 This insulation of the data from direct access by the
called data hiding or information
program is
hiding.
Data Abstraction
 Abstraction refers to the act of representing essential
features without including the background details or
explanations.
 Classes use the concept of abstraction and are
defined as a list of abstract attributes such as size,
weight and cost, and functions to operate on these
functions.
 Since the classes use the concept of data
abstraction, they are known as Abstract Data
Types.
Inheritance
 Inheritance is the process by which objects of one
class acquire the properties of objects of another
class.
 The principle behind this sort of division is that each
derived class shares common characteristics with the
class from which it is derived. (Base class)
 In OOP the concept of inheritance provides the
idea of reusability.
 This means that we can add additional features to an
existing class without modifying it.
Inheritance
 The real power of inheritance mechanism is that it
allows the programmer to reuse a class that is almost
but not exactly, what he wants, and to tailor the class
in such a way that it does not introduce any
undesirable side-effects into the rest of the classes.
Bird
Flying Bird No flying Bird
Polymorphism
 Polymorphism means the ability to take more than one
form.
 That is an operation may exhibit different behaviours
in different instances. The behaviour depends upon
the types of data used in the operation.
Example: Operation of addition.
 For two numbers the operation will generate a sum.
 If the operands are strings, then the operation would
produce a third string by concatenation.
Polymorphism
 The process of making an operator to exhibit different
behaviours in different instances is known as
operator overloading.
 Using a single function name to perform different types
of tasks is known as function overloading.
Dynamic Binding
 Binding refers to the linking of a procedure call to the
code to be executed in response to the call.
 "Binding" means associating a function for a
particular function call.
 Dynamic binding means that the code associated with
a given procedure call is not known until the time of
the call at run-time.
 It is associated with polymorphism and
inheritance.
Message Communication
 An object-oriented program consists of a set of
objects that communicate with each other.
 Object communicate with one another by sending and
receiving information much the same way as people
pass message to one another.
 Message passing involves specifying the name of the
object, the name of the funciton (message) and the
information to be sent.
emp.salary(emp_name);
object
message
information
Benefits of OOP
 Through inheritance we can elimate the redundant
code and extend the use of existing code
 Data hiding helps the programmer to build secure
programs that cannot be invaded by code in other
parts of the program
 It is possible to have mulitple instances of an objects
to co-exist without any interference.
 Easy to partition the work in a project based on objects
Benefits of OOP
 Data-centreddesign approachenables us to capture
more details of a model in implementable form
 Object-oriented systems can be easily upgraded
from small to large systems. Easy to read the code
and debug
 Message passing techniques for communication
between objects makes the interface descriptions with
external systems much simpler.
 Software complexity can be easily managed.

POP vs OOP Introduction

  • 1.
  • 2.
    Programming Language :Definition A vocabulary and set of grammatical rules for instructing a computer to perform specific tasks.
  • 3.
    Programming Languages Programmer useProgramming languages to develop the software. The three major families of languages are: oMachine languages oAssembly languages oHigh-Level languages
  • 4.
    Machine Languages Comprised of1s and 0s The “native” language of a computer Difficult to program – one misplaced 1 or 0 will cause the program to fail. Example of code: 1110100010101 111010101110
  • 5.
    Assembly Languages Assembly languagesare a step towards easier programming. Assembly languages are comprised of a set of elemental commands. (MNEMONICS) Assembly language code needs to be translated to machine language before the computer processes it. Example: LOAD BASEPAY ADD OVERPAY STORE GROSSPAY
  • 6.
    High-Level Languages High-level languagesrepresent a giant leap towards easier programming. The syntax of HL languages is similar to English. Historically, we divide HL languages into two groups: Procedural Oriented Programming Object-Oriented Programming (OOP)
  • 7.
    Procedure-Oriented Programming Large programsare divided into Smaller Programs know as function. Most of the functions share global data. Data move openly around the system from function to function. Top-down approach in program design.
  • 8.
    Object -Oriented Programming Strikingfeature Programs are divided into what are known as objects. Data is hidden and cannot be accessed by external functions. Program can be easily extend whenever necessary. Bottom-up approach in program design.
  • 9.
     Structured programmingenable programmers to write moderately complex programs fairly easily.  However as the programs grew larger, even the structured approach failed to show the desired results in terms of bug-free, easy-to-maintain and reusable programs.
  • 10.
     Object-Oriented Programming(OOP) is an appraoch to program organization and development that attempts to elimate some of the pitfalls of conventional programming methods by incorporating the best of structured programming features with several powerful new concepts.
  • 11.
    Procedure-Oriented Programming  Conventionalprogramming using high level language such as COBOL, FORTRAN and C is commonly known as Procedure-oriented programming.  In the Procedure-oriented approach the problem is viewed as a sequence of things to be done.  The primary focus is on functions.
  • 12.
    Structure of Procedure-oriented MainProgram Function 1 Function 2 Function 3 Function 5 Function 4
  • 13.
    Procedure-Oriented Programming  Procudure-orientedprogramming basically consists of writing a list of instructions for the computer to follow and organizing these instructions into groups known as functions.
  • 14.
    Structure of Procedure-oriented Globaldata Function 2 Global data Function 3 Function 1 Local data Local data Local data
  • 15.
    Procedure-Oriented Programming  Whathappens to data? How are they affected by the functions that work on them?  In multi-function program many important data items are placed as global so that they may be accessed by all the functions.Each function may have its own local data.  In large program it is very difficult to identify what data is used by which function. In case we need to revise an external data structure we also need to revise all function that access it.
  • 16.
    Object-Oriented Programming  OOPtreats data as a critical element in the program development and does not allow it to flow freely around the system.  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 entites called objects.
  • 17.
    Organization of data& function OOP Data Functions Data Functions Data Functions Object C ObjectA Object B
  • 18.
    Basic concepts ofOOP  Objects  Class  Data Abstration  Encapsulation  Inheritance  Polyomorphism  Dynamic binding  Message Passing The three pillars of object-oriented development:  Encapsulation, Inheritance, and Polymorphism.
  • 19.
    Object Object is areal world entity, for example, chair, car, pen, mobile, laptop etc. In other words, object is an entity that has state and behavior. Here, state means data and behavior means functionality. Object is a runtime entity, it is created at runtime. Object is an instance of a class. All the members of the class can be accessed through object. Let's see an example to create object of student class using s1 as the reference variable. Student s1; //creating an object of Student
  • 20.
  • 21.
  • 22.
    Class Class is amodel for creating objects. A class is the building block, that leads to Object-Oriented programming. A class is thus a collection of objects of similar types.  It is a user-defined data type, which holds its own data members and member functions, which can be accessed and used by creating an instance of that class. A class is like a blueprint for an object or blueprint for creating objects (a particular data structure), providing initial values for state (member variables or attributes), and implementations of behavior (member functions or methods).
  • 23.
    Class Class is atemplate from which objects are created. It can have fields, methods. The user-defined objects are created using the class keyword.  The class is a blueprint that defines a nature of a future object. An instance is a specific object created from a particular class. Classes are used to create and manage new objects and support inheritance—a key ingredient in object-oriented programming and a mechanism of reusing code
  • 24.
    Classes  Once aclass has been defined we can create any number of objects belonging to that class.
  • 27.
    Classes  Fruit isa class defined as a Class.  fruit f1;  Here fruit is Class.  And f1 is an object of fruit Class.
  • 28.
    Encapsulation  The wrappingup of data and functions into a single unit is known as Encapsulation  The data is not accessible to the outside world and only those functions which are wrapped in the class can access it.  This insulation of the data from direct access by the called data hiding or information program is hiding.
  • 29.
    Data Abstraction  Abstractionrefers to the act of representing essential features without including the background details or explanations.  Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, weight and cost, and functions to operate on these functions.  Since the classes use the concept of data abstraction, they are known as Abstract Data Types.
  • 30.
    Inheritance  Inheritance isthe process by which objects of one class acquire the properties of objects of another class.  The principle behind this sort of division is that each derived class shares common characteristics with the class from which it is derived. (Base class)  In OOP the concept of inheritance provides the idea of reusability.  This means that we can add additional features to an existing class without modifying it.
  • 31.
    Inheritance  The realpower of inheritance mechanism is that it allows the programmer to reuse a class that is almost but not exactly, what he wants, and to tailor the class in such a way that it does not introduce any undesirable side-effects into the rest of the classes. Bird Flying Bird No flying Bird
  • 32.
    Polymorphism  Polymorphism meansthe ability to take more than one form.  That is an operation may exhibit different behaviours in different instances. The behaviour depends upon the types of data used in the operation. Example: Operation of addition.  For two numbers the operation will generate a sum.  If the operands are strings, then the operation would produce a third string by concatenation.
  • 33.
    Polymorphism  The processof making an operator to exhibit different behaviours in different instances is known as operator overloading.  Using a single function name to perform different types of tasks is known as function overloading.
  • 34.
    Dynamic Binding  Bindingrefers to the linking of a procedure call to the code to be executed in response to the call.  "Binding" means associating a function for a particular function call.  Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run-time.  It is associated with polymorphism and inheritance.
  • 35.
    Message Communication  Anobject-oriented program consists of a set of objects that communicate with each other.  Object communicate with one another by sending and receiving information much the same way as people pass message to one another.  Message passing involves specifying the name of the object, the name of the funciton (message) and the information to be sent. emp.salary(emp_name); object message information
  • 36.
    Benefits of OOP Through inheritance we can elimate the redundant code and extend the use of existing code  Data hiding helps the programmer to build secure programs that cannot be invaded by code in other parts of the program  It is possible to have mulitple instances of an objects to co-exist without any interference.  Easy to partition the work in a project based on objects
  • 37.
    Benefits of OOP Data-centreddesign approachenables us to capture more details of a model in implementable form  Object-oriented systems can be easily upgraded from small to large systems. Easy to read the code and debug  Message passing techniques for communication between objects makes the interface descriptions with external systems much simpler.  Software complexity can be easily managed.