Week 1 L2
Week 1 L2
Programming (OOP)
Week 01
WEEK 01 | Lecture 02
Introduction to OO paradigm
Principles of Object Oriented Paradigm
PROGRAMMING PARADIGMS
Sequential
Procedural
Object Oriented
needed.
Object
Oriented
Differences between Procedural and Object
Oriented Programming
Procedural Programming Object Oriented Programming
In procedural programming, program is In object oriented programming, program is
divided into small parts called functions. divided into small parts called objects.
Procedural programming follows top down Object oriented programming follows bottom
approach. up approach.
Examples: C, FORTRAN, Pascal, Basic etc. Example: C++, Java, Python, C# etc.
WHAT IS OBJECT ORIENTATION?
Highway maps
Architectural models
Mechanical models
Example – OO Model
Example – OO Model
Objects
Ali
House
Car
Tree
Interactions
Ali lives in the house
Ali drives the car
Object-Orientation - Advantages
An object is
Something tangible (Ali, Car)
Something that can be apprehended intellectually (Time, Date)
An object has
State (attributes)
Well-defined behaviors (operations)
Unique identity
Example – Ali is a Tangible Object
State (attributes)
Name
Age
Behaviors (operations)
Walks
Eats
Identity
His name
Example – Car is a Tangible Object
State (attributes)
Color
Model
Behavior (operations)
Accelerate
Start Car
Change Gear
Identity
Its registration number
Example – Time is an Object Apprehended
Intellectually
State (attributes)
Hours
Seconds
Minutes
Behavior (operations)
Set Hours
Set Seconds
Set Minutes
Identity
Would have a unique ID in the model
Example – Date is an Object Apprehended
Intellectually
State (attributes)
Year
Day
Month
Behavior (operations)
Set Year
Set Day
Set Month
Identity
Would have a unique ID in the model