0% found this document useful (0 votes)
61 views9 pages

Introduction To Object Oriented Programming

Object oriented programming (OOP) was developed to address some flaws in procedure oriented programming (POP). OOP focuses on modeling real-world objects like data rather than procedures. In OOP, programs are divided into objects that encapsulate both data and functions. Data is hidden and can only be accessed by associated functions, improving modularity and security. Key concepts in OOP include objects, classes, encapsulation, inheritance, polymorphism, and message passing.

Uploaded by

Vishal Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views9 pages

Introduction To Object Oriented Programming

Object oriented programming (OOP) was developed to address some flaws in procedure oriented programming (POP). OOP focuses on modeling real-world objects like data rather than procedures. In OOP, programs are divided into objects that encapsulate both data and functions. Data is hidden and can only be accessed by associated functions, improving modularity and security. Key concepts in OOP include objects, classes, encapsulation, inheritance, polymorphism, and message passing.

Uploaded by

Vishal Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Introduction to Object Oriented

Programming
Procedure Oriented Programming
 Conventional Programming, using high-level
languages such as COBOL, FORTRAN and C, is
commonly known as Procedure Oriented
Programming (POP).
 In POP approach, the problem is viewed as a
sequence of things to be done as reading,
calculating and printing.
 A number of functions are written to
accomplish these tasks.
 The primary focus is on functions.
Characteristics of POP:
 Emphasis is on doing things (algorithms).
 Large programs are divided into smaller programs known as functions.
 Most of the functions share global data.
 Data move openly around the system from function to function.
 Functions transform data from one form to another.
 Employs top-down approach in program design.
 Disadvantage of POP:
◦ In a large program, it is very difficult to identify which data is used by which function. In case we
need to revise an external data structure, we also need to revise all the functions that access the
data. This provides an opportunity for the bugs to creep in..
◦ It does not model real world problems very well. This is because the functions are action oriented
and do not really correspond to the elements of the same problem.
Object Oriented Programming
 This approach was invented to remove some of the flaws of POP.
 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 other functions.
 OOP allows decomposition of problem into number of entities called Objects and than builds data and
functions around these objects.
 The data of an object can be accessed only by the functions associated with that object. However,
functions of one object can access the functions of other objects.
Features of OOP
 Emphasis is on data rather than procedure.
 Programs are divided into what are known as objects.
 Data structures are designed such that they characterize the objects.
 Functions that operate on data of an object are tied together in the data structures.
 Data is hidden and cannot be accessed by external functions.
 Objects may communicate with each other through functions.
 New data and functions can be easily added whenever necessary.
 Follows bottom-up approach in program design.

 Therefore, Object oriented programming can be defined as an approach that provides a


way of modularizing programs by creating partitioned memory area for both data and
functions that can be used as templates for creating copies of such modules on demand.
Basic concepts of Object Oriented Programming
 Objects
 Classes
 Data abstraction and Encapsulation
 Inheritance
 Polymorphism
 Dynamic Binding
 Message passing
Objects
 Objects are basic run time entities in an object oriented system.
 They may represent a person, a place, a bank account, a table of data or an item that the
program has to handle.
 They may also represent user defined data such as vectors, time and lists.
 Programming problem is analyzed in terms of objects and nature of communication
between them.
 Program objects should be chosen such that they match closely with the real world objects.
 Characteristics of Objects:
◦ Identity or the name associated with object
◦ States
◦ Behavior: what the object does and what it is capable of doing.
 Example: Pitcher
◦ Identity: Pitcher
◦ States: Upright, Full/Empty, Broken, Material-Clay, Colour- Brown
◦ Behavior: Can be filled/emptied/ transparent/ Broken.
 In normal programming, when we write a program about (say) pitcher, the states are
represented by variables and the behavior as functions.
 When a program is executed, the objects interact by sending messages to one another.
 Each object contains data and code to manipulate the data.
Object: Student

Data:
Name
Date-of-birth
Marks
Functions:
Total
Average
Display
Classes
 The entire set of data and code of an object can be made a user defined data type with the
help of a class.
 In fact, objects are variables of the type class.
 Once a class has been defined, we can create any number of objects of that class.
 Each object is associated with the data of type class with which they are created.
 A class is thus a collection of objects of similar type.
 Classes are user defined data types and behaves like the built in data types of a
programming language.

You might also like