Anda di halaman 1dari 14

Object-Oriented Programming (OOP)

http://ecomputernotes.com

Object-Orientation (OO)

http://ecomputernotes.com

What is Object-Orientation?
A

technique for system modeling model consists of several interacting objects

OO

http://ecomputernotes.com

What is a Model?
A

model is an abstraction of something

Purpose

is to understand the product before developing it

http://ecomputernotes.com

Examples Model
Highway

maps models

Architectural Mechanical

models

http://ecomputernotes.com

Example OO Model

http://ecomputernotes.com

Example OO Model
Objects

Smith
drives

lives-in

House

Ali House Car Tree


Interactions

Car

Tree

Ali lives in the house Ali drives the car


http://ecomputernotes.com

Object-Orientation - Advantages
People OO

think in terms of objects

models map to reality OO models are

Therefore,

easy to develop easy to understand


http://ecomputernotes.com

What is an Object?
An object is
Something Something

tangible (Ali, Car)

that can be apprehended intellectually (Time, Date)

http://ecomputernotes.com

What is an Object?
An object has
State

(attributes) Well-defined behaviour (operations) Unique identity

http://ecomputernotes.com

Example Smith is a Tangible Object


State

(attributes)

Name Age
behaviour

(operations)

Walks Eats
Identity

His name
http://ecomputernotes.com

Example Car is a Tangible Object


State

(attributes)

- Color - Model
behaviour

(operations)
- Start Car

- Accelerate - Change Gear


Identity

- Its registration number


http://ecomputernotes.com

Example Time is an Object Apprehended Intellectually


State

(attributes)
- Seconds

- Hours - Minutes
behaviour

(operations)
- Set Seconds

- Set Hours - Set Minutes


Identity

- Would have a unique ID in the model


http://ecomputernotes.com

Example Date is an Object Apprehended Intellectually


State

(attributes)
- Day

- Year - Month
behaviour

(operations)
- Set Day

- Set Year - Set Month


Identity

- Would have a unique ID in the model


http://ecomputernotes.com

Anda mungkin juga menyukai