Lecture 01
Lecture 01
Object-Oriented Programming
(OOP)
Lecture No. 1
► Highway maps
► Architectural models
► Mechanical models
► State (attributes)
► Well-defined behaviour (operations)
► Unique identity
► State (attributes)
Name
Age
► behaviour (operations)
Walks
Eats
► Identity
His name
Engr. Nabeel Ali © CS1201 - Object Oriented Programming 15
Example – Car is a Tangible Object
► State (attributes)
- Color
- Model
► behaviour (operations)
- Accelerate - Start Car
- Change Gear
► Identity
- Its registration number
Engr. Nabeel Ali © CS1201 - Object Oriented Programming 16
Example – Time is an Object
Apprehended Intellectually
► State (attributes)
- Hours - Seconds
- Minutes
► behaviour (operations)
- Set Hours - Set Seconds
- Set Minutes
► Identity
- Would have a unique ID in the model
► We don’t know
How the data is stored
How Ali translates this information
Engr. Nabeel Ali © CS1201 - Object Oriented Programming 24
Example – Encapsulation
►A Phone stores phone numbers in digital
format and knows how to convert it into
human-readable characters
► We don’t know
How the data is stored
How it is converted to human-readable
characters
► Low complexity
► Better understanding
► This includes
Data structures to hold object state
Functionality that provides required services
► Data Structure
Mechanical structure of gear box
► Functionality
Mechanism to change gear
► Data Structure
SIM card
► Functionality
Read/write circuitry
► Low Complexity
► Principle of abstraction:
► Attributes
- Name - Employee ID
- Student Roll No - Designation
- Year of Study - Salary
- CGPA - Age
► behaviour
- Study - DevelopExam
- GiveExam - TakeExam
- PlaySports - Eat
- DeliverLecture - Walk
► Attributes
- Name - Employee ID
- Student Roll No - Designation
- Year of Study - Salary
- CGPA - Age
► behaviour
- Study - DevelopExam
- GiveExam - TakeExam
- PlaySports - Eat
- DeliverLecture - Walk
► Attributes
- Name - Employee ID
- Student Roll No - Designation
- Year of Study - Salary
- CGPA - Age
► behaviour
- Study - DevelopExam
- GiveExam - TakeExam
- PlaySports - Eat
- DeliverLecture - Walk
Engineer’s View
Driver’s View
(Class Name)
(Class Name)
(attributes)
Suppressed
(operations)
Form
Normal Form
Engr. Nabeel Ali © CS1201 - Object Oriented Programming 52
Example – Graphical Representation
of Classes
Circle
center Circle
radius
draw Suppressed
computeArea Form
Normal Form
Engr. Nabeel Ali © CS1201 - Object Oriented Programming 53
Example – Graphical Representation
of Classes
Person
name Person
age
gender Suppressed
eat Form
walk
Normal Form
Engr. Nabeel Ali © CS1201 - Object Oriented Programming 54
The END