Object Oriented Programming: By: Irfan U. Memon
Object Oriented Programming: By: Irfan U. Memon
• Foundations of Programming
Programming Fundamentals
Outlines
• Programming Paradigms
• Object Oriented Programming
(OOP)?
• Need of OOP
• Classes
• Objects
• How to create Objects
Programming Paradigms
Data
Logic
What Object Orientation is ?
• Programming Paradigm
• Not a programming Language.
• Set of Ideas that is supported by many
programming languages.
e.g C++, Java, C#, Php, Objective-C (Many others)
Object Oriented Programming Languages.
Object Oriented Programming (OOP)
What is An Object?
What are object in real world?
• Things
• Is this desk?
• This Computer?
• A Pen?
Attributes Behavior
name Walk
Height Run
Weight Jump
Gender Speak
age sleep
What does a class Describe
Properties Methods
name Walk
Height Run
Weight Jump
Gender Speak
age sleep
Object Oriented Paradigm
• Abstraction
• Polymorphism
• Inheritance
• Encapsulation
Abstraction
• Focus on the essentials
• Ignore the Irrelevant
• Ignore the unimportant
• Not the separate class, one generalized
class
• Focuses on how our class would look
like rather than what is our class
Encapsulation
• Idea of surrounding something
• Bundling the attributes and behavior in
the same class.
• Also want restrict access in or out of
the class. (Data Hiding)
• Black Boxing.
• Why Hiding?
Inheritance
• Creating a class based on another class
• Code Re-use
• Base Class is know as Super class
• New formed class as Child Class
Polymorphism
• Poly “Many”, morph “shapes”
• It enables us automatically do the
correct behavior even if what we are
working with can take many forms.
• (+) sign
Methods
• method is a code block that contains a series of statements