SlideShare a Scribd company logo
1
INTRODUCTION TO OOP
Objective:
•Know the difference between functional programmin
and OOP
• Know basic terminology in OOP
• Know the importance of OOP
• Know four design principles of OOP
• Know OOP programming languages
Programming Paradigm
A programming paradigm is a style, or
“way,” of programming
Types of Programming
Paradigm
Imperative: Programming with an explicit
sequence of commands that update state.
Declarative: Programming by specifying
the result you want, not how to get it.
Object-Oriented: Programming by
defining objects that send messages to
each other. Objects have their own
internal (encapsulated) state and public
interfaces.
Types of Programming
Paradigm…
Object orientation can be:
Class-based: Objects get state and behavior
based on membership in a class.
Prototype-based: Objects get behavior from
a prototype object.
Structured: Programming with clean,
goto-free, nested control structures.
Procedural: Imperative programming
with procedure calls.
Types of Programming
Paradigm..
Event-Driven: Programming with emitters and
listeners of asynchronous actions.
Flow-Driven: Programming processes
communicating with each other over
predefined channels.
Functional (Applicative): Programming with
function calls that avoid any global state.
Function-Level (Combinator): Programming
with no variables at all.
Types of Programming
Paradigm..
Logic (Rule-based): Programming by
specifying a set of facts and rules. An
engine infers the answers to questions.
Constraint: Programming by specifying
a set of constraints. An engine finds the
values that meet the constraints.
Aspect-Oriented: Programming cross-
cutting concerns applied transparently.
7
STRUCTURED vs. OO PROGRAMMING
STRUCTURED PROGRAMMING:
MAIN PROGRAM
FUNCTION 3
FUNCTION 2
GLOBAL DATA
FUNCTION 5
FUNCTION 4
FUNCTION 1
8
Structured Programming
Using function
Function & program is divided into modules
Every module has its own data and function
which can be called by other modules.
9
OBJECT ORIENTED PROGRAMMING
Object 1
Object 2
Data
Function
Data
Function
Object 3
Data
Function
10
OBJECT ORIENTED PROGRAMMING
•Objects have both data and methods
• Objects of the same class have the same data
elements and methods
• Objects send and receive messages to invoke
actions
Key idea in object-oriented:
The real world can be accurately described as a collection of
objects that interact.
11
Basic terminology
Basic terminology
•object
- usually a person, place or thing (a noun)
•method
- an action performed by an object (a verb)
•attribute
- description of objects in a class
•class
- a category of similar objects (such as
automobiles)
- does not hold any values of the object’s attributes
12
Example for attributes and methods
Attributes:
manufacturer’s
name
model name
year made
color
number of doors
size of engine
etc.
Methods:
Define data items
(specify
manufacturer’s name,
model, year, etc.)
Change a data item
(color, engine, etc.)
Display data items
Calculate cost
etc.
13
Why OOP?
• Save development time (and cost) by reusing
code
–once an object class is created it can be used
in other applications
• Easier debugging
–classes can be tested independently
–reused objects have already been tested
14
Design Principles of OOP
Four main design principles of Object-
Oriented Programming(OOP):
• Encapsulation
• Abstraction
• Polymorphism
• Inheritance
15
Encapsulation
•Also known as data hiding
•Only object’s methods can modify information
in the object.
Analogy:
• ATM machine can only update accounts of one
person or object only.
16
Abstraction
Focus only on the important facts about the
problem at hand
to design, produce, and describe so that it can be
easily used without knowing the details of how it
works.
Analogy:
When you drive a car, you don’t have to know how
the gasoline and air are mixed and ignited.
Instead you only have to know how to use the
controls.
Draw map
17
Polymorphism
•the same word or phrase can mean different
things in different contexts
Analogy:
•In English, bank can mean side of a river or a
place to put money
•move -
18
Function Overloading
The operation of one function depends on
the argument passed to it.
Example: Fly(), Fly(low), Fly(150)
19
Inheritance
• Inheritance—a way of organizing classes
• Term comes from inheritance of traits like eye
color, hair color, and so on.
• Classes with properties in common can be
grouped so that their common properties are
only defined once.
• Superclass – inherit its attributes & methods to
the subclass(es).
• Subclass – can inherit all its superclass
attributes & methods besides having its own
unique attributes & methods.
20
An Inheritance Hierarchy
Vehicle
Automobile Motorcycle Bus
Sedan Sports Car School Bus
Luxury Bus
What properties does each vehicle inherit from the types
of vehicles above it in the diagram?
Superclass
Subclasses
21
Object-Oriented Programming Languages
 Pure OO Languages
Smalltalk, Eiffel, Actor, Java
 Hybrid OO Languages
C++, Objective-C, Object-Pascal

More Related Content

Similar to Introduction.ppt JAVA SCRIPT PROGRAMMING AND (20)

chapterOne.pptxFSdgfqdzwwfagxgghvkjljhcxCZZXvcbx
chapterOne.pptxFSdgfqdzwwfagxgghvkjljhcxCZZXvcbxchapterOne.pptxFSdgfqdzwwfagxgghvkjljhcxCZZXvcbx
chapterOne.pptxFSdgfqdzwwfagxgghvkjljhcxCZZXvcbx
berihun18
 
1 intro
1 intro1 intro
1 intro
abha48
 
OOP programming
OOP programmingOOP programming
OOP programming
anhdbh
 
OOP-1.pptx
OOP-1.pptxOOP-1.pptx
OOP-1.pptx
iansebuabeh
 
Bab satu
Bab satuBab satu
Bab satu
Aida Ramlan II
 
babsatu-140703233001-phpapp666666601.pdf
babsatu-140703233001-phpapp666666601.pdfbabsatu-140703233001-phpapp666666601.pdf
babsatu-140703233001-phpapp666666601.pdf
kashafishfaq21
 
Computer_Programming_Part_II_Segment_01.pdf
Computer_Programming_Part_II_Segment_01.pdfComputer_Programming_Part_II_Segment_01.pdf
Computer_Programming_Part_II_Segment_01.pdf
et243047
 
Total oop in c# dot net
Total oop in c# dot netTotal oop in c# dot net
Total oop in c# dot net
Muhammad Naveed
 
Different paradigms for problem solving.pptx
Different paradigms for problem solving.pptxDifferent paradigms for problem solving.pptx
Different paradigms for problem solving.pptx
iitjeesooraj
 
POP vs OOP Introduction
POP vs OOP IntroductionPOP vs OOP Introduction
POP vs OOP Introduction
Hashni T
 
the Concept of Object-Oriented Programming
the Concept of Object-Oriented Programmingthe Concept of Object-Oriented Programming
the Concept of Object-Oriented Programming
Aida Ramlan II
 
JAVA PROGRAMMINGD
JAVA PROGRAMMINGDJAVA PROGRAMMINGD
JAVA PROGRAMMINGD
Niyitegekabilly
 
Basics of object oriented programming interview tips for Java
Basics of object oriented programming interview tips for JavaBasics of object oriented programming interview tips for Java
Basics of object oriented programming interview tips for Java
Martin A
 
Object Oriented Programming Part 2 of Unit 1
Object Oriented Programming Part 2 of Unit 1Object Oriented Programming Part 2 of Unit 1
Object Oriented Programming Part 2 of Unit 1
VigneshkumarPonnusam1
 
Birasa 1
Birasa 1Birasa 1
Birasa 1
Niyitegekabilly
 
JAVA PROGRAMMING
JAVA PROGRAMMING JAVA PROGRAMMING
JAVA PROGRAMMING
Niyitegekabilly
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
Jasleen Kaur (Chandigarh University)
 
6_Object-oriented-using-java.pdf object oriented programming concepts
6_Object-oriented-using-java.pdf object oriented programming concepts6_Object-oriented-using-java.pdf object oriented programming concepts
6_Object-oriented-using-java.pdf object oriented programming concepts
harinipradeep15
 
UNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPU
UNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPUUNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPU
UNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPU
ApurvaLaddha
 
Unit1 jaava
Unit1 jaavaUnit1 jaava
Unit1 jaava
mrecedu
 
chapterOne.pptxFSdgfqdzwwfagxgghvkjljhcxCZZXvcbx
chapterOne.pptxFSdgfqdzwwfagxgghvkjljhcxCZZXvcbxchapterOne.pptxFSdgfqdzwwfagxgghvkjljhcxCZZXvcbx
chapterOne.pptxFSdgfqdzwwfagxgghvkjljhcxCZZXvcbx
berihun18
 
1 intro
1 intro1 intro
1 intro
abha48
 
OOP programming
OOP programmingOOP programming
OOP programming
anhdbh
 
babsatu-140703233001-phpapp666666601.pdf
babsatu-140703233001-phpapp666666601.pdfbabsatu-140703233001-phpapp666666601.pdf
babsatu-140703233001-phpapp666666601.pdf
kashafishfaq21
 
Computer_Programming_Part_II_Segment_01.pdf
Computer_Programming_Part_II_Segment_01.pdfComputer_Programming_Part_II_Segment_01.pdf
Computer_Programming_Part_II_Segment_01.pdf
et243047
 
Different paradigms for problem solving.pptx
Different paradigms for problem solving.pptxDifferent paradigms for problem solving.pptx
Different paradigms for problem solving.pptx
iitjeesooraj
 
POP vs OOP Introduction
POP vs OOP IntroductionPOP vs OOP Introduction
POP vs OOP Introduction
Hashni T
 
the Concept of Object-Oriented Programming
the Concept of Object-Oriented Programmingthe Concept of Object-Oriented Programming
the Concept of Object-Oriented Programming
Aida Ramlan II
 
Basics of object oriented programming interview tips for Java
Basics of object oriented programming interview tips for JavaBasics of object oriented programming interview tips for Java
Basics of object oriented programming interview tips for Java
Martin A
 
Object Oriented Programming Part 2 of Unit 1
Object Oriented Programming Part 2 of Unit 1Object Oriented Programming Part 2 of Unit 1
Object Oriented Programming Part 2 of Unit 1
VigneshkumarPonnusam1
 
6_Object-oriented-using-java.pdf object oriented programming concepts
6_Object-oriented-using-java.pdf object oriented programming concepts6_Object-oriented-using-java.pdf object oriented programming concepts
6_Object-oriented-using-java.pdf object oriented programming concepts
harinipradeep15
 
UNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPU
UNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPUUNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPU
UNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPU
ApurvaLaddha
 
Unit1 jaava
Unit1 jaavaUnit1 jaava
Unit1 jaava
mrecedu
 

Recently uploaded (20)

Unit 20 LEGAL_ETHICAL_SHEET the one .docx
Unit 20 LEGAL_ETHICAL_SHEET the one .docxUnit 20 LEGAL_ETHICAL_SHEET the one .docx
Unit 20 LEGAL_ETHICAL_SHEET the one .docx
157551
 
How to Prepare for Palo Alto XDR Analyst Certification.pdf
How to Prepare for Palo Alto XDR Analyst Certification.pdfHow to Prepare for Palo Alto XDR Analyst Certification.pdf
How to Prepare for Palo Alto XDR Analyst Certification.pdf
Aakruthi Singh
 
422073_45847_3 (1).pdfggggggggggggggguiii
422073_45847_3 (1).pdfggggggggggggggguiii422073_45847_3 (1).pdfggggggggggggggguiii
422073_45847_3 (1).pdfggggggggggggggguiii
bikbikash24
 
最新版西班牙巴斯克大学毕业证(UPV毕业证书)原版定制
最新版西班牙巴斯克大学毕业证(UPV毕业证书)原版定制最新版西班牙巴斯克大学毕业证(UPV毕业证书)原版定制
最新版西班牙巴斯克大学毕业证(UPV毕业证书)原版定制
Taqyea
 
Professor Dr. Nazrul Islam, School of Business and Entrepreneurship, Independ...
Professor Dr. Nazrul Islam, School of Business and Entrepreneurship, Independ...Professor Dr. Nazrul Islam, School of Business and Entrepreneurship, Independ...
Professor Dr. Nazrul Islam, School of Business and Entrepreneurship, Independ...
Dr. Nazrul Islam
 
The best Strategies for Developing your Resume
The best Strategies for Developing your ResumeThe best Strategies for Developing your Resume
The best Strategies for Developing your Resume
marcojaramillohenao0
 
#5 Selection of the Human resource(1).pptx
#5 Selection of the Human resource(1).pptx#5 Selection of the Human resource(1).pptx
#5 Selection of the Human resource(1).pptx
siddharthchaturvedi0
 
PEACH Jobs Board - (Updated on June 12th)
PEACH Jobs Board - (Updated on June 12th)PEACH Jobs Board - (Updated on June 12th)
PEACH Jobs Board - (Updated on June 12th)
PEACHOrgnization
 
最新版美国休斯顿大学毕业证(UH毕业证书)原版定制
最新版美国休斯顿大学毕业证(UH毕业证书)原版定制最新版美国休斯顿大学毕业证(UH毕业证书)原版定制
最新版美国休斯顿大学毕业证(UH毕业证书)原版定制
Taqyea
 
t20 world cup journey OF INDIA IN WEST INDIES
t20 world cup journey OF INDIA IN WEST INDIESt20 world cup journey OF INDIA IN WEST INDIES
t20 world cup journey OF INDIA IN WEST INDIES
manpreetkaur3469
 
"Housefull 5" (.2025.) +Fu𝗅𝗅Mov𝗂e! Down𝗅oad Fre𝖾 𝟩𝟤𝟢𝗉, 𝟦𝟪𝟢𝗉 𝖧𝖣 & 𝟣𝟢𝟪𝟢𝗉
"Housefull 5" (.2025.) +Fu𝗅𝗅Mov𝗂e! Down𝗅oad Fre𝖾 𝟩𝟤𝟢𝗉, 𝟦𝟪𝟢𝗉 𝖧𝖣 & 𝟣𝟢𝟪𝟢𝗉"Housefull 5" (.2025.) +Fu𝗅𝗅Mov𝗂e! Down𝗅oad Fre𝖾 𝟩𝟤𝟢𝗉, 𝟦𝟪𝟢𝗉 𝖧𝖣 & 𝟣𝟢𝟪𝟢𝗉
"Housefull 5" (.2025.) +Fu𝗅𝗅Mov𝗂e! Down𝗅oad Fre𝖾 𝟩𝟤𝟢𝗉, 𝟦𝟪𝟢𝗉 𝖧𝖣 & 𝟣𝟢𝟪𝟢𝗉
deltaforcedxb7
 
Detection to Communicationnnnnnnnnnn.pptx
Detection to Communicationnnnnnnnnnn.pptxDetection to Communicationnnnnnnnnnn.pptx
Detection to Communicationnnnnnnnnnn.pptx
rtanvi1518
 
ACEN presentation / huddle from June 2025
ACEN presentation / huddle from June 2025ACEN presentation / huddle from June 2025
ACEN presentation / huddle from June 2025
Mark Rauterkus
 
Bone Histology and benign bone tumo.pptx
Bone Histology and benign bone tumo.pptxBone Histology and benign bone tumo.pptx
Bone Histology and benign bone tumo.pptx
lohanikritika1
 
A Guide for a Winning Interview June 2025
A Guide for a Winning Interview June 2025A Guide for a Winning Interview June 2025
A Guide for a Winning Interview June 2025
Bruce Bennett
 
Top HR interview question and answer.pdf
Top HR interview question and answer.pdfTop HR interview question and answer.pdf
Top HR interview question and answer.pdf
mbbseo1
 
👉 Top 11 IT Companies in Hinjewadi You Should Know About
👉 Top 11 IT Companies in Hinjewadi You Should Know About👉 Top 11 IT Companies in Hinjewadi You Should Know About
👉 Top 11 IT Companies in Hinjewadi You Should Know About
vaishalitraffictail
 
Strengths Based CV Template untuk latihan.docx
Strengths Based CV Template untuk latihan.docxStrengths Based CV Template untuk latihan.docx
Strengths Based CV Template untuk latihan.docx
W Diana Ratri M.Psi, Psikolog
 
MODULE TILT WELD SEQrrUENCE updated.pptx
MODULE TILT WELD SEQrrUENCE updated.pptxMODULE TILT WELD SEQrrUENCE updated.pptx
MODULE TILT WELD SEQrrUENCE updated.pptx
akashsunilghallal
 
4099319-Market_Research_on_SKILLCIRCLE.pdf
4099319-Market_Research_on_SKILLCIRCLE.pdf4099319-Market_Research_on_SKILLCIRCLE.pdf
4099319-Market_Research_on_SKILLCIRCLE.pdf
ParimalTripura
 
Unit 20 LEGAL_ETHICAL_SHEET the one .docx
Unit 20 LEGAL_ETHICAL_SHEET the one .docxUnit 20 LEGAL_ETHICAL_SHEET the one .docx
Unit 20 LEGAL_ETHICAL_SHEET the one .docx
157551
 
How to Prepare for Palo Alto XDR Analyst Certification.pdf
How to Prepare for Palo Alto XDR Analyst Certification.pdfHow to Prepare for Palo Alto XDR Analyst Certification.pdf
How to Prepare for Palo Alto XDR Analyst Certification.pdf
Aakruthi Singh
 
422073_45847_3 (1).pdfggggggggggggggguiii
422073_45847_3 (1).pdfggggggggggggggguiii422073_45847_3 (1).pdfggggggggggggggguiii
422073_45847_3 (1).pdfggggggggggggggguiii
bikbikash24
 
最新版西班牙巴斯克大学毕业证(UPV毕业证书)原版定制
最新版西班牙巴斯克大学毕业证(UPV毕业证书)原版定制最新版西班牙巴斯克大学毕业证(UPV毕业证书)原版定制
最新版西班牙巴斯克大学毕业证(UPV毕业证书)原版定制
Taqyea
 
Professor Dr. Nazrul Islam, School of Business and Entrepreneurship, Independ...
Professor Dr. Nazrul Islam, School of Business and Entrepreneurship, Independ...Professor Dr. Nazrul Islam, School of Business and Entrepreneurship, Independ...
Professor Dr. Nazrul Islam, School of Business and Entrepreneurship, Independ...
Dr. Nazrul Islam
 
The best Strategies for Developing your Resume
The best Strategies for Developing your ResumeThe best Strategies for Developing your Resume
The best Strategies for Developing your Resume
marcojaramillohenao0
 
#5 Selection of the Human resource(1).pptx
#5 Selection of the Human resource(1).pptx#5 Selection of the Human resource(1).pptx
#5 Selection of the Human resource(1).pptx
siddharthchaturvedi0
 
PEACH Jobs Board - (Updated on June 12th)
PEACH Jobs Board - (Updated on June 12th)PEACH Jobs Board - (Updated on June 12th)
PEACH Jobs Board - (Updated on June 12th)
PEACHOrgnization
 
最新版美国休斯顿大学毕业证(UH毕业证书)原版定制
最新版美国休斯顿大学毕业证(UH毕业证书)原版定制最新版美国休斯顿大学毕业证(UH毕业证书)原版定制
最新版美国休斯顿大学毕业证(UH毕业证书)原版定制
Taqyea
 
t20 world cup journey OF INDIA IN WEST INDIES
t20 world cup journey OF INDIA IN WEST INDIESt20 world cup journey OF INDIA IN WEST INDIES
t20 world cup journey OF INDIA IN WEST INDIES
manpreetkaur3469
 
"Housefull 5" (.2025.) +Fu𝗅𝗅Mov𝗂e! Down𝗅oad Fre𝖾 𝟩𝟤𝟢𝗉, 𝟦𝟪𝟢𝗉 𝖧𝖣 & 𝟣𝟢𝟪𝟢𝗉
"Housefull 5" (.2025.) +Fu𝗅𝗅Mov𝗂e! Down𝗅oad Fre𝖾 𝟩𝟤𝟢𝗉, 𝟦𝟪𝟢𝗉 𝖧𝖣 & 𝟣𝟢𝟪𝟢𝗉"Housefull 5" (.2025.) +Fu𝗅𝗅Mov𝗂e! Down𝗅oad Fre𝖾 𝟩𝟤𝟢𝗉, 𝟦𝟪𝟢𝗉 𝖧𝖣 & 𝟣𝟢𝟪𝟢𝗉
"Housefull 5" (.2025.) +Fu𝗅𝗅Mov𝗂e! Down𝗅oad Fre𝖾 𝟩𝟤𝟢𝗉, 𝟦𝟪𝟢𝗉 𝖧𝖣 & 𝟣𝟢𝟪𝟢𝗉
deltaforcedxb7
 
Detection to Communicationnnnnnnnnnn.pptx
Detection to Communicationnnnnnnnnnn.pptxDetection to Communicationnnnnnnnnnn.pptx
Detection to Communicationnnnnnnnnnn.pptx
rtanvi1518
 
ACEN presentation / huddle from June 2025
ACEN presentation / huddle from June 2025ACEN presentation / huddle from June 2025
ACEN presentation / huddle from June 2025
Mark Rauterkus
 
Bone Histology and benign bone tumo.pptx
Bone Histology and benign bone tumo.pptxBone Histology and benign bone tumo.pptx
Bone Histology and benign bone tumo.pptx
lohanikritika1
 
A Guide for a Winning Interview June 2025
A Guide for a Winning Interview June 2025A Guide for a Winning Interview June 2025
A Guide for a Winning Interview June 2025
Bruce Bennett
 
Top HR interview question and answer.pdf
Top HR interview question and answer.pdfTop HR interview question and answer.pdf
Top HR interview question and answer.pdf
mbbseo1
 
👉 Top 11 IT Companies in Hinjewadi You Should Know About
👉 Top 11 IT Companies in Hinjewadi You Should Know About👉 Top 11 IT Companies in Hinjewadi You Should Know About
👉 Top 11 IT Companies in Hinjewadi You Should Know About
vaishalitraffictail
 
MODULE TILT WELD SEQrrUENCE updated.pptx
MODULE TILT WELD SEQrrUENCE updated.pptxMODULE TILT WELD SEQrrUENCE updated.pptx
MODULE TILT WELD SEQrrUENCE updated.pptx
akashsunilghallal
 
4099319-Market_Research_on_SKILLCIRCLE.pdf
4099319-Market_Research_on_SKILLCIRCLE.pdf4099319-Market_Research_on_SKILLCIRCLE.pdf
4099319-Market_Research_on_SKILLCIRCLE.pdf
ParimalTripura
 
Ad

Introduction.ppt JAVA SCRIPT PROGRAMMING AND

  • 1. 1 INTRODUCTION TO OOP Objective: •Know the difference between functional programmin and OOP • Know basic terminology in OOP • Know the importance of OOP • Know four design principles of OOP • Know OOP programming languages
  • 2. Programming Paradigm A programming paradigm is a style, or “way,” of programming
  • 3. Types of Programming Paradigm Imperative: Programming with an explicit sequence of commands that update state. Declarative: Programming by specifying the result you want, not how to get it. Object-Oriented: Programming by defining objects that send messages to each other. Objects have their own internal (encapsulated) state and public interfaces.
  • 4. Types of Programming Paradigm… Object orientation can be: Class-based: Objects get state and behavior based on membership in a class. Prototype-based: Objects get behavior from a prototype object. Structured: Programming with clean, goto-free, nested control structures. Procedural: Imperative programming with procedure calls.
  • 5. Types of Programming Paradigm.. Event-Driven: Programming with emitters and listeners of asynchronous actions. Flow-Driven: Programming processes communicating with each other over predefined channels. Functional (Applicative): Programming with function calls that avoid any global state. Function-Level (Combinator): Programming with no variables at all.
  • 6. Types of Programming Paradigm.. Logic (Rule-based): Programming by specifying a set of facts and rules. An engine infers the answers to questions. Constraint: Programming by specifying a set of constraints. An engine finds the values that meet the constraints. Aspect-Oriented: Programming cross- cutting concerns applied transparently.
  • 7. 7 STRUCTURED vs. OO PROGRAMMING STRUCTURED PROGRAMMING: MAIN PROGRAM FUNCTION 3 FUNCTION 2 GLOBAL DATA FUNCTION 5 FUNCTION 4 FUNCTION 1
  • 8. 8 Structured Programming Using function Function & program is divided into modules Every module has its own data and function which can be called by other modules.
  • 9. 9 OBJECT ORIENTED PROGRAMMING Object 1 Object 2 Data Function Data Function Object 3 Data Function
  • 10. 10 OBJECT ORIENTED PROGRAMMING •Objects have both data and methods • Objects of the same class have the same data elements and methods • Objects send and receive messages to invoke actions Key idea in object-oriented: The real world can be accurately described as a collection of objects that interact.
  • 11. 11 Basic terminology Basic terminology •object - usually a person, place or thing (a noun) •method - an action performed by an object (a verb) •attribute - description of objects in a class •class - a category of similar objects (such as automobiles) - does not hold any values of the object’s attributes
  • 12. 12 Example for attributes and methods Attributes: manufacturer’s name model name year made color number of doors size of engine etc. Methods: Define data items (specify manufacturer’s name, model, year, etc.) Change a data item (color, engine, etc.) Display data items Calculate cost etc.
  • 13. 13 Why OOP? • Save development time (and cost) by reusing code –once an object class is created it can be used in other applications • Easier debugging –classes can be tested independently –reused objects have already been tested
  • 14. 14 Design Principles of OOP Four main design principles of Object- Oriented Programming(OOP): • Encapsulation • Abstraction • Polymorphism • Inheritance
  • 15. 15 Encapsulation •Also known as data hiding •Only object’s methods can modify information in the object. Analogy: • ATM machine can only update accounts of one person or object only.
  • 16. 16 Abstraction Focus only on the important facts about the problem at hand to design, produce, and describe so that it can be easily used without knowing the details of how it works. Analogy: When you drive a car, you don’t have to know how the gasoline and air are mixed and ignited. Instead you only have to know how to use the controls. Draw map
  • 17. 17 Polymorphism •the same word or phrase can mean different things in different contexts Analogy: •In English, bank can mean side of a river or a place to put money •move -
  • 18. 18 Function Overloading The operation of one function depends on the argument passed to it. Example: Fly(), Fly(low), Fly(150)
  • 19. 19 Inheritance • Inheritance—a way of organizing classes • Term comes from inheritance of traits like eye color, hair color, and so on. • Classes with properties in common can be grouped so that their common properties are only defined once. • Superclass – inherit its attributes & methods to the subclass(es). • Subclass – can inherit all its superclass attributes & methods besides having its own unique attributes & methods.
  • 20. 20 An Inheritance Hierarchy Vehicle Automobile Motorcycle Bus Sedan Sports Car School Bus Luxury Bus What properties does each vehicle inherit from the types of vehicles above it in the diagram? Superclass Subclasses
  • 21. 21 Object-Oriented Programming Languages  Pure OO Languages Smalltalk, Eiffel, Actor, Java  Hybrid OO Languages C++, Objective-C, Object-Pascal