OOPOOPObject Oriented ProgrammingObject Oriented Programming
By : Tauseef Ahmad (107)
Evolution of OOPEvolution of OOP
1,0
Machine Language
Assembly Language
Procedure-Oriented
Object-Oriented Programming
Procedure-OrientedProcedure-Oriented
• The primary focus is on functions.
• It basically consist of list of instructions for computer
to follow, and to organize these instructions into
groups known as functions.
Structure of POPStructure of POP
[Procedure oriented programming][Procedure oriented programming]
Main Program
Function-1 Function-2 Function-3
Function-4 Function-5
Function-6 Function-7 Function-8
Drawbacks of POPDrawbacks of POP
• Most of the function share global data.
• It does not model real world problem very well.
Global data Global data
Function-1 Function-1 Function-1
Local Data Local Data Local Data
Object-Oriented LanguagesObject-Oriented Languages
• Object-oriented programming is not the right of any
particular language.
• Like structured programming, OOP concept can be
implemented using any language like C and
Pascal.
Object-Oriented ParadigmObject-Oriented Paradigm
• Object-oriented programming (OOP) is a
programming paradigm that uses "Objects" and
their interactions to design applications and
computer programs.
• Everything around us are objects interacting with
each others.
• Each object has a set of features, including
adjectives and verbs.
• Object-oriented paradigms is sometimes thought to
be a simulation of the real-world around us, which
make it the paradigm of choice for most
application domains: GUIs, games, business, etc.
Basic concepts of OOPBasic concepts of OOP
• Objects
• Classes
• Data Abstraction and Encapsulation
• Inheritance
• Polymorphism
• Dynamic Binding
• Message Passing
ObjectsObjects
• Objects are the run-time entities.
• It may represent a person, a place, a bank
account, a table of data or any item.
• Objects take up space in the memory and have an
associated address like a structure in c.
• Some examples : car, man, woman etc
ClassesClasses
• A class is an abstract definition of an object.
• Defines how would the object look like when
created.
• Think of classes like the patents of actual inventions.
EncapsulationEncapsulation
• Wrapping up of data and functions into a single unit
is known as Encapsulation.
• Encapsulation is hiding the functional details from
the object calling it.
• Can you drive a car?
o Yes, I can!
• So, how does acceleration work?
o Huh?
• Details encapsulated (hidden) from the driver.
Data AbstractionData Abstraction
• Abstraction refers to the act of representing
essential features without including the background
details or explanation.
• An abstraction is a form of representation that
includes only what is useful or interesting from a
particular viewpoint.
• Example : A map is an abstract representation,
since no map shows every detail of the territory it
covers
InheritanceInheritance
• Inheritance is the process by which objects of one
class acquire the properties of objects of another
class.
name
phoneNumber
address
hourlyWage
WageContract()
CalculateTax()
PayTuition()
DropCourse()
Professor
name
phoneNumber
address
salary
TeachCourse()
CalculateTax()
DevelopCourse()
OR
Employee
name
phoneNumber
address
CalculateTax()
SupportStaff Professor
TeachCourse()
DevelopCourse()
salary
Subclasses
WageContract()
hourlyWage
SupportStaff
InheritanceInheritance
Man
Suzuki
Woman
BMW
Car Human
PolymorphismPolymorphism
int add(int a, int b, int c)
{
return (a+b+c); It will return addition
} of 3 integer numbers
int add(int a,int b)
{
return (a+b); It will return addition
} of 2 integer numbers
float add(float a, float b, float c)
{
return (a+b+c); It will return addition
} of 3 float numbers
PolymorphismPolymorphism
• Polymorphism is a Greek term means the ability to
take more than one form.
Shape
Draw()
Circle Object
Draw (circle)
Box Object
Draw (box)
Triangle Object
Draw (triangle)
Message PassingMessage Passing
• The process by which an object:
o Sends data to another object.
o Asks the other object to invoke a method.
• In other words, objects talk to each others via
messages.
18
Object and Their InteractionObject and Their Interaction
Program
19
Object and Their InteractionObject and Their Interaction
Program
Tom, hold your sweep!
20
Object and Their InteractionObject and Their Interaction
Program
Tom, hold your sweep!
Tom, beat jerry!
21
Object and Their InteractionObject and Their Interaction
Program
Tom.holdYourSweep()
Tom.BeatJerry()
IN PROGRAMMING
22
Object and Their InteractionObject and Their Interaction
Program
Tom.holdYourSweep()
Tom.BeatJerry()
IN PROGRAMMING
message
23
Object and Their InteractionObject and Their Interaction
Program
Tom.holdYourSweep()
Tom.BeatJerry()
IN PROGRAMMING
message
message

Oop’s

  • 1.
    OOPOOPObject Oriented ProgrammingObjectOriented Programming By : Tauseef Ahmad (107)
  • 2.
    Evolution of OOPEvolutionof OOP 1,0 Machine Language Assembly Language Procedure-Oriented Object-Oriented Programming
  • 3.
    Procedure-OrientedProcedure-Oriented • The primaryfocus is on functions. • It basically consist of list of instructions for computer to follow, and to organize these instructions into groups known as functions.
  • 4.
    Structure of POPStructureof POP [Procedure oriented programming][Procedure oriented programming] Main Program Function-1 Function-2 Function-3 Function-4 Function-5 Function-6 Function-7 Function-8
  • 5.
    Drawbacks of POPDrawbacksof POP • Most of the function share global data. • It does not model real world problem very well. Global data Global data Function-1 Function-1 Function-1 Local Data Local Data Local Data
  • 6.
    Object-Oriented LanguagesObject-Oriented Languages •Object-oriented programming is not the right of any particular language. • Like structured programming, OOP concept can be implemented using any language like C and Pascal.
  • 7.
    Object-Oriented ParadigmObject-Oriented Paradigm •Object-oriented programming (OOP) is a programming paradigm that uses "Objects" and their interactions to design applications and computer programs. • Everything around us are objects interacting with each others. • Each object has a set of features, including adjectives and verbs. • Object-oriented paradigms is sometimes thought to be a simulation of the real-world around us, which make it the paradigm of choice for most application domains: GUIs, games, business, etc.
  • 8.
    Basic concepts ofOOPBasic concepts of OOP • Objects • Classes • Data Abstraction and Encapsulation • Inheritance • Polymorphism • Dynamic Binding • Message Passing
  • 9.
    ObjectsObjects • Objects arethe run-time entities. • It may represent a person, a place, a bank account, a table of data or any item. • Objects take up space in the memory and have an associated address like a structure in c. • Some examples : car, man, woman etc
  • 10.
    ClassesClasses • A classis an abstract definition of an object. • Defines how would the object look like when created. • Think of classes like the patents of actual inventions.
  • 11.
    EncapsulationEncapsulation • Wrapping upof data and functions into a single unit is known as Encapsulation. • Encapsulation is hiding the functional details from the object calling it. • Can you drive a car? o Yes, I can! • So, how does acceleration work? o Huh? • Details encapsulated (hidden) from the driver.
  • 12.
    Data AbstractionData Abstraction •Abstraction refers to the act of representing essential features without including the background details or explanation. • An abstraction is a form of representation that includes only what is useful or interesting from a particular viewpoint. • Example : A map is an abstract representation, since no map shows every detail of the territory it covers
  • 13.
    InheritanceInheritance • Inheritance isthe process by which objects of one class acquire the properties of objects of another class. name phoneNumber address hourlyWage WageContract() CalculateTax() PayTuition() DropCourse() Professor name phoneNumber address salary TeachCourse() CalculateTax() DevelopCourse() OR Employee name phoneNumber address CalculateTax() SupportStaff Professor TeachCourse() DevelopCourse() salary Subclasses WageContract() hourlyWage SupportStaff
  • 14.
  • 15.
    PolymorphismPolymorphism int add(int a,int b, int c) { return (a+b+c); It will return addition } of 3 integer numbers int add(int a,int b) { return (a+b); It will return addition } of 2 integer numbers float add(float a, float b, float c) { return (a+b+c); It will return addition } of 3 float numbers
  • 16.
    PolymorphismPolymorphism • Polymorphism isa Greek term means the ability to take more than one form. Shape Draw() Circle Object Draw (circle) Box Object Draw (box) Triangle Object Draw (triangle)
  • 17.
    Message PassingMessage Passing •The process by which an object: o Sends data to another object. o Asks the other object to invoke a method. • In other words, objects talk to each others via messages.
  • 18.
    18 Object and TheirInteractionObject and Their Interaction Program
  • 19.
    19 Object and TheirInteractionObject and Their Interaction Program Tom, hold your sweep!
  • 20.
    20 Object and TheirInteractionObject and Their Interaction Program Tom, hold your sweep! Tom, beat jerry!
  • 21.
    21 Object and TheirInteractionObject and Their Interaction Program Tom.holdYourSweep() Tom.BeatJerry() IN PROGRAMMING
  • 22.
    22 Object and TheirInteractionObject and Their Interaction Program Tom.holdYourSweep() Tom.BeatJerry() IN PROGRAMMING message
  • 23.
    23 Object and TheirInteractionObject and Their Interaction Program Tom.holdYourSweep() Tom.BeatJerry() IN PROGRAMMING message message