Sie sind auf Seite 1von 17

Procedure Oriented Programming

The procedure oriented programming characterizes a program as a series of user-defined functions Given problem (verbal/written description of a problem) is split into more manageable modules Then design a number of data structures that hold our data and we implement a number of functions to operate on this data
Object Oriented Programming - Introduction R.B. Lenin Winter 2007 DA-IICT 5

Procedure Oriented Programming

These functions would modify the data structures, store them to files and also print them So, all knowledge about the system is built into a set of functions The prime focus is on these functions which is the style of procedure oriented programming
Object Oriented Programming - Introduction R.B. Lenin Winter 2007 DA-IICT 6

Procedure Oriented Programming

Object Oriented Programming - Introduction

R.B. Lenin

Winter 2007

DA-IICT

Procedure Oriented Programming A procedure-oriented code can be thought of as code acting on data Information that is more important to us is in the data stored in data structures The functions we implement are simple tools to modify these data structures
Object Oriented Programming - Introduction R.B. Lenin Winter 2007 DA-IICT 8

Procedure Oriented Programming


These functions never change in a running programming, but the data in the different data structures keeps changing In a multi-function program with the procedure oriented programming approach, many important data items are placed as global so that they may be accessed by all the functions besides each function having its own local data
Object Oriented Programming - Introduction R.B. Lenin Winter 2007 DA-IICT 9

Procedure Oriented Programming

Object Oriented Programming - Introduction

R.B. Lenin

Winter 2007

DA-IICT

10

Procedure Oriented Programming Global data are more vulnerable to an inadvertent change by a function In a 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 the data
Object Oriented Programming - Introduction R.B. Lenin Winter 2007 DA-IICT 11

Procedure Oriented Programming


To summarize, in the procedure oriented programming Emphasis is on creating functions 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
Object Oriented Programming - Introduction R.B. Lenin Winter 2007 DA-IICT 12

Procedure Oriented Programming Problems with this approach will start appear as programs grow larger and more complex For example, C employs this approach to considerable success To manage increasing complexity, the second approach, called Object Oriented Programming (OOP), was conceived
Object Oriented Programming - Introduction R.B. Lenin Winter 2007 DA-IICT 13

Objected 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 It allows decomposition of a problem into a number of entities called objects and then builds data and functions around these objects
Object Oriented Programming - Introduction R.B. Lenin Winter 2007 DA-IICT 14

Organization of data and functions in OOP

Object Oriented Programming - Introduction

R.B. Lenin

Winter 2007

DA-IICT

15

Object Oriented Programming OOP is 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 Therefore, an object is considered to be a partitioned area of computer memory that stores data and set of operations that can access that data.
Object Oriented Programming - Introduction R.B. Lenin Winter 2007 DA-IICT 16

Cruise Control System

Object Oriented Programming - Introduction

R.B. Lenin

Winter 2007

DA-IICT

17

Cruise Control System as set of Objects

Object Oriented Programming - Introduction

R.B. Lenin

Winter 2007

DA-IICT

18

Object Oriented Programming


The aim of OOP is to shift the focus of attention from procedures that do things to data which is asked to do things. The task is not to define the procedures which manipulate data, but to define data objects and their attributes and the way in which they may be examined or changed Data objects and procedures can communicate with other data objects only through narrow, well-defined channels
19

Object Oriented Programming - Introduction

R.B. Lenin

Winter 2007

DA-IICT

Object Oriented Programming - Introduction

R.B. Lenin

Winter 2007

DA-IICT

20

Objected Oriented Programming


To summarize, in OOP Emphasis is on data rather than functions Programs are divided into what are known as objects Data structures are designed such that they characterize the objects Functions that operate on the data of an object are tied together in the data structure 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

Object Oriented Programming - Introduction

R.B. Lenin

Winter 2007

DA-IICT

21

Das könnte Ihnen auch gefallen