0% found this document useful (0 votes)
13 views20 pages

1 (20 Files Merged)

This document provides an introduction to object-oriented programming (OOP). It discusses how OOP was created to overcome flaws in procedural programming like lack of reusability and maintainability. The key concepts of OOP include objects, classes, encapsulation, inheritance, and polymorphism. Objects contain both data and functions, and classes are templates for creating objects. Communication between objects occurs through functions and messages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views20 pages

1 (20 Files Merged)

This document provides an introduction to object-oriented programming (OOP). It discusses how OOP was created to overcome flaws in procedural programming like lack of reusability and maintainability. The key concepts of OOP include objects, classes, encapsulation, inheritance, and polymorphism. Objects contain both data and functions, and classes are templates for creating objects. Communication between objects occurs through functions and messages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Introduction to

0 bj ect-Oriented
Programming

Prese nted By :
Krisha n Pa l
Singh
JDAT
O bject-Orient ed Programmin g
• OOP was introduced to overcome flaws in
the procedural approach to programming.
• Such as lacl< of reusability &
maintainability.
• Fun damental idea behind object-oriented
languages is to combine into a single unit
both data and the functions th a t operate
o n t h at data .
• Such a unit is called an o bject .
Object-Orie nted Programming
• In OOP, problem is divided into the number of
entities called object s and then builds data
and functions around these objects.
• It ties the data more closely to the functions
that operate on it, and protects it from
accidental mod ification from the outside
functions.
• Data of an object can be accessed only by
the functions associated with th at object .
• Commun ication of the objects done
through function .
Object-Orie nted Programming

-...

Fig 3: Object-Oriented
paradigm
Object-Oriented Programming
Ch aracte ristics :
• Empl1asis on da ta rather than proced ure.
• Programs are divided in to en tities known as objects.
• Data Structures are d esigned such tha t t hey characterize
objects.
• Functions that operate on da ta of an object are
tied together in da ta structures.
• Data is hid den and cann ot be accessed by
external functions.
• Objects comm unicate with each other through
fun ctions.
• New da ta and functions can be easily added
whenever necessary.
• Follows bottom up d esign in program design .
Bottom up approach
• Reverse top-down approach.
• Lower level tasks are first carried out and are
then integrated to provide the solution of a single
program.
• Lower level st ructures of th e program are
evolved first then higher level stru ctures are
created.
• It promotes code reuse.
• It may allow unit testing.
Basic Co ncepts of o o ps
i. Objects
2. Classes
3. Data Abstraction
4. Data Encapsulation
5. Inheritance
6. Polymorphism
7. Dynam ic bind ing
8. Message Passing
Objects

Operation

Operation Att ribu te s O peration

Opera tion
Objects
• Objects are the basic run-time entities of
an object oriented system.
• They may represent a person, a place or
any item that the program must handle .
• Example:

Fig 4: Represen tation of


object.
Objects
• When a program is executed , the
object s interact by sending messages to
one another.
• For e.g. if "customer" and "account" are
two objects in a program, then the
customer
object may send a message to the account
object requesting for the bank balance.
• Each object contains data, and code to
manipulate the data.
Classe s

@
@
<i!>
@)
@
@
@
Class
Why Do We Ne ed Object-Oriented
Program ming?

• Object-Oriented Programming was


developed because limitations were discovered
in earlier approaches to programmi ng.

• To appreciate what OOP does, we need to


understan d what these limitation s are and how t hey
arose from traditional
programming languages.
Classes
• Classes are user-defined data types and it
behaves like built in types of
programming language.
• Object contains code and data which can be
made user define type using class.
• Objects are variables of class.
• Once a class has been defined we can
create any number of objects for th at class.
• A class is collections of objects of
similar type.
Procedure-Oriented Programm ing
• C, Pascal, FORTRAN, and similar languages
are proced ural languages.
• Each statemen t in the language tells the com puter
to do something:
- get some input
- add these numbers
- d ivide by 6
- display that output
• A program in a proced ural language is a list of
instruction s.
Procedure-Oriented Programm ing

Division into Fun ctions:


• Procedural program is divid ed into functions
• Each function has a clearly defined purpose and
a clearly defmed interface to the other functions
in t he program.
• The idea of breaking a program into functions
can be further extend ed by grou ping a nu mber of
functions together into a larger entity called a
module .
Procedure-Oriented Programm in g
Division int o Functions:

Main Progr:un

J-unct ion I f unct ion f unct ion


2 3
"-.. "-.. /
Funct ion 4 Funct ion
..........._ 5
/ . ' --............
Fune I ion o Funet ion 7 .
Function 1!
Fig i : Structure of Procedure-Oriented
Programming
Procedure-Ori ented Programm in g
• In Multi-function program important data
items are placed as global so that they
may be accessed by all functions.
• Each function may have its own local data.

Global d ta Global da ta Global d a ta

Func Func i Functi Functi


ion on on on

Fig 2 : Procedural
p aradigm
Procedure-Oriented Programm ing
Drawback s :
• Since every function has complete access to the
global variables, the new progra m mer cai1 corrupt
the data accidentally by creating function.
• We can access the data of one function from other
since, there is no protection.
• In large program it is very difficu lt to identify what data
is used by which function.
• Similarly, i f new data is to be added, all the
function needed to be modified to access the data.
• Does not model real world problem very well.
Procedure-Oriented Programm ing
Characteristics :
• Emphasis is on doing things (algorith ms).
• Large programs are divided into smaller programs
known as functio ns .
• Most of the functions share global data.
• Data move openly arou nd the system from function to
function.
• Functions tra nsform data from one form to another.
• Employs top-down ap proach in program design.
Top-Down Approach
• Top-down decomposi tion is the process of breaking t he
overall procedure or task into component parts (mod ules)
and then su bd ivide each component module until the
lowest level of detail has been reached.
• Example :The payroll system of a company can contain
the following mod ules or tasks
- Master fiJ e
- Earnings
- Deductions
- Taxing
- Net earning
- Print reports

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy