IntroToOOP
IntroToOOP
Programming
Presented by
I. Sakthidevi., ME., (PhD)
Assistant Professor
Department of IT
Adhiyamaan College of Engineering
(An Autonomous Institution),Hosur
1
INTRODUCTION TO OOP
Objective:
2
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.
3
OBJECT ORIENTED PROGRAMMING
Object 2
Object 1
Data Data
Function Function
Object 3
Data
Function
4
OBJECT ORIENTED PROGRAMMING
5
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 6
Example for attributes and methods
Attributes: Methods:
manufacturer’s Define data items
name (specify
manufacturer’s name,
model name model, year, etc.)
year made Change a data item
color (color, engine, etc.)
Display data items
number of doors
Calculate cost
size of engine etc.
etc.
7
Why OOP?
8
Design Principles of OOP
• Encapsulation
• Abstraction
• Polymorphism
• Inheritance
9
10
11
12
13
14
15
16
17
18
19
20
21
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
22
23
Encapsulation
Analogy:
• ATM machine can only update accounts of
one person or object only.
24
25
26
Inheritance
Superclass
Vehicle
Subclasses
28
29
30
Polymorphism
Analogy:
•In English, bank can mean side of a river
or a place to put money
•move -
31
Function Overloading
32
Object-Oriented Programming Languages
Pure OO Languages
Smalltalk, Eiffel, Actor, Java
Hybrid OO Languages
C++, Objective-C, Object-Pascal
33
34