1 (20 Files Merged)
1 (20 Files Merged)
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
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:
@
@
<i!>
@)
@
@
@
Class
Why Do We Ne ed Object-Oriented
Program ming?
Main Progr:un
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