Introduction: Object Oriented
Programming
DARWIN VARGAS
Today’s Contents
Structured Language and Object-
oriented Language
Why OOP?
Basic concepts of OOP
2
Structured Language
and
Object-oriented Language
3
Structured / Procedure
Programming Methodology (SPM)
4
Basic features of SPM
Emphasis on doing algorithms.
Large Programs are divided into smaller programs known as Functions
Most of the function shares global data.
Data move around the system globally from function to function.
Function transfers the data from one form to another.
Employs top-down approach of Programming.
Example: C, Pascal, FORTRAN
5
Problems with Structured Programming
Methodology (SPM)
• Reach their limit when project becomes too large.
• Large program became more complex.
• Functions have unrestricted access to global data.
6
OOP - Breaking the Barriers of SPM
7
Key Points
Took the best ideas of SPM and combine with several new
concepts.
Combine into a single unit both data and the functions that
operate on that data.
You can’t access the data directly.
The data is hidden, so it is safe from accidental alteration.
Data encapsulation and data hiding are key terms in the
description of object-oriented languages.
8
The striking features of OOP
Emphasis on data rather than the procedure.
Programs are divided into objects.
Data are hidden and can’t be accessed by external functions
Object may communicate with each other through methods
(functions).
New data & functions can be easily added whenever necessary.
9
Concepts of OOP
• Object
• Class
• Methods
• Instance Variables (Properties)
10
1. Object
• Real world entity.
• Bundle of related variables and functions (also known
methods).
• Objects share two characteristics:
1. Properties / State
2. Method / Behavior (Functionalities)
11
Two characteristics of Object
• Objects share two characteristics:
1. Properties / State
» State is a well-defined condition of an item.
» A state captures the relevant aspects of an object
2. Method / Behavior (Functionalities)
» Behavior is the observable effects of an operation or event
12
Example
Object: House
States: Color
Location
Behaviors: Close/open doors
13
Try?
Object: Car
States(Properties): ?
Behaviors(Functions):
?
14
Try?
Object: Car
States(Properties): Color,
Model#, Wheel
Behaviors(Functions): Move,
Break
15
Try?
Object: ?
States(Properties): ?
Behaviors(Functions): ?
16
2. Class
• A class can be defined as a template/blueprint of an
object that describes the behaviors/states that object.
Class: A template/blueprint of an objects
Class: A template/blueprint of an objects
Object Oriented Analysis
20
What is Object Oriented Analysis?
Account
Account
Holder
Monthly
Transaction
Banking Software
Branch
Employee
Problem Domain
Objects
Noun Phrase
21
Have a try
?
?
?
University
?
?
Problem Domain
Objects
22
SelfWork
?
?
?
? ?
?
Problem Domain Objects
23
Detailing Objects
Account
Bank Holder
Account Holder
Account Has: name, contact
no, accounts
Branch Account
Branch Has : A/C Number, Employee
Balance, Opening Date,
Has: Name, Location, Account Holder details Employee
No of accounts
Does: Has: name, id, email,
Does: Create new Deposit money, salary
accounts, make Withdraw money
transaction Does: Handle banking
transactions
24
Detailing Objects
Bank
Account Holder
Account
Attributes : name,
Branch contact no, accounts
Attributes :
Attributes: Name, Number, Balance,
Location, Opening Date.
No of accounts Account Holder
Employee
Function: Create Function :
new accounts Deposit given
Attributes : name,
amount
id, email,
Withdraw given
salary
amount
Functions: Handle
banking transactions
25
Objects are inter-connected
Account Holder
Account
Has: name, contact
Branch no, accounts
Has : Number,
Has: Name, Balance, Opening
Location, Date. Account
No of accounts Holder
Employee
Does: Create new Does:
accounts Deposit given
Has: name, id,
amount
email,
Withdraw given
salary
amount
Does: Handle
banking transactions
26
Detail objects of University
and Find their inter-connection
?
?
?
University
?
?
Problem Domain Objects
27
Thank you!
28