0% found this document useful (0 votes)
61 views17 pages

Week 1 L2

This document introduces object-oriented programming (OOP) and compares it to procedural programming. It discusses how OOP uses objects rather than functions to divide a program into small parts. Objects contain both data (attributes) and behaviors (operations). OOP follows a bottom-up approach and allows for data hiding, inheritance, and polymorphism. Real-world entities like people, places, and things can be modeled as objects in OOP.

Uploaded by

Farrukh Abbas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views17 pages

Week 1 L2

This document introduces object-oriented programming (OOP) and compares it to procedural programming. It discusses how OOP uses objects rather than functions to divide a program into small parts. Objects contain both data (attributes) and behaviors (operations). OOP follows a bottom-up approach and allows for data hiding, inheritance, and polymorphism. Real-world entities like people, places, and things can be modeled as objects in OOP.

Uploaded by

Farrukh Abbas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

CS1004- Object-Oriented

Programming (OOP)
Week 01
WEEK 01 | Lecture 02

Introduction to OO paradigm
Principles of Object Oriented Paradigm
PROGRAMMING PARADIGMS

Sequential
Procedural
Object Oriented

Which paradigm is best?


Think in term of data that we
needed.
Data
Oriented

Think in term of process that


we needed.
Process
Oriented

Think in term of object that is


PROGRAMMING PARADIGMS

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.

There is no access specifier in procedural Object oriented programming have access


programming. specifiers like private, public, protected etc.
Adding new data and function is not easy. Adding new data and function is easy.
Procedural programming does not have any Object oriented programming provides data
proper way for hiding data so it is less secure. hiding so it is more secure.
Differences between Procedural and Object
Oriented Programming
Procedural Programming Object Oriented Programming
In procedural programming, overloading is Overloading is possible in object oriented
not possible. programming.
Procedural programming is based on unreal Object oriented programming is based on real
world. world.

Examples: C, FORTRAN, Pascal, Basic etc. Example: C++, Java, Python, C# etc.
WHAT IS OBJECT ORIENTATION?

A technique for system modeling


OO model consists of several interacting objects
What is a Model?

A model is an abstraction of something


Purpose is to understand the product before developing it
Examples – Model

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

People think in terms of objects


OO models map to reality
Therefore, OO models are
easy to develop
easy to understand
What is an Object?

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

You might also like