cn if2261 intro tooo

13

Click here to load reader

Upload: khaerul-azmi

Post on 23-Jun-2015

270 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Cn if2261 intro tooo

1

Page 1

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 1

R

Introduction to Object Orientation

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 2

R

Objectives: Introduction to Object Orientation

w Understand the basic principles of object orientation w Define the basic concepts and terms of object orientationw Discuss the strengths of object orientation w Understand some basic UML modeling mechanisms

Page 2: Cn if2261 intro tooo

2

Page 2

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 3

R

Introduction to Object Orientation Topics

w Basic Principles of Object Orientationw Basic Concepts of Object Orientationw General UML Modeling Mechanisms

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 4

R

Basic Principles of Object Orientation

Object Orientation

Enca

psul

atio

n

Abst

ract

ion

Hier

arch

y

Mod

ular

ity

Page 3: Cn if2261 intro tooo

3

Page 3

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 5

R

What is Abstraction?

Customer

Salesperson

Product

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 6

R

What is Encapsulation?

w Hide implementation from clients§ Clients depend on interface

Page 4: Cn if2261 intro tooo

4

Page 4

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 7

R

What is Modularity?

w The breaking up of something complex into manageable pieces

Order Processing System

Billing

OrderEntry

OrderFulfillment

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 8

R

What is Hierarchy?

Decreasing abstraction

Increasing abstraction

Asset

RealEstate

Savings

BankAccount

Checking Stock

Security

Bond

Classes at the same level of the hierarchy should be at the same level of abstraction

w Levels of abstraction

Page 5: Cn if2261 intro tooo

5

Page 5

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 9

R

Introduction to Object Orientation Topics

w Basic Principles of Object Orientationw Basic Concepts of Object Orientationw General UML Modeling Mechanisms

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 10

R

Basic Concepts of Object Orientation

w Objectw Classw Attributew Operationw Componentw Generalizationw Polymorphism

Page 6: Cn if2261 intro tooo

6

Page 6

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 11

R

What is an Object?

w Behaviorw Statew Unique identity

English 101

Geology 110

Geology 110World History 200

Algebra 110Music History 200

Intro to OO 180

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 12

R

What is a Class?

w An object is defined by a class

English 101

Geology 110

Geology 110World History 200

Algebra 110Music History 200

Intro to OO 180

CourseOffering

Page 7: Cn if2261 intro tooo

7

Page 7

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 13

R

What is an Attribute?

:CourseOfferingnumber = 101startTime = 900endTime = 1100

:CourseOfferingName = 104startTime = 1300endTime = 1500

CourseOfferingnumberstartTime endTime

Class

Attribute

Object

Attribute Value

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 14

R

What is an Operation?

CourseOffering

addStudent deleteStudentgetStartTimegetEndTime

Class

Operation

Page 8: Cn if2261 intro tooo

8

Page 8

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 15

R

w A non-trivial, nearly independent, and replaceable part of a system that fulfills a clear function in the context of a well-defined architecture

<<subsystem>>Component Name

ComponentName

What Is A Component?

Design Model Implementation Model

Component Interface

Component Interface

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 16

R

What is Generalization?

w One class inherits from another

Truck

tonnage

GroundVehicle

weightlicenseNumber

Car

owner

register( )

getTax( )

Person

0..*

Trailer

1ancestor

decendent

generalization

size

Page 9: Cn if2261 intro tooo

9

Page 9

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 17

R

What is Polymorphism?

w The ability to hide many different implementations behind a single interface

Manufactor AManufactor A

Manufactor C

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 18

R

Strengths of Object Orientation

w A single paradigm§ Single language used by users, analysts, designers,

implementersw Facilitates architectural and code reusew Models more closely reflect the real world§ More accurately describe corporate data and processes§ Decomposed based on natural partitioning§ Easier to understand and maintain

w Stability§ A small change in requirements does not mean massive

changes in the system under development

Page 10: Cn if2261 intro tooo

10

Page 10

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 19

R

A Simple Sales Order Example

Order

Product

Ship via

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 20

R

Class Diagram for the Sales Example

Salesperson Product

Sale

Corporate

Customer

Individual Truck

Vehicle

Train

Page 11: Cn if2261 intro tooo

11

Page 11

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 21

R

Effect of Requirements Change

Only the Truck class changes

Suppose the requirementsfor shipping by a truckchange ...

Salesperson Product

Sale

Corporate

Customer

Individual Truck

Vehicle

Train

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 22

R

Introduction to Object Orientation Topics

w Basic Principles of Object Orientationw Basic Concepts of Object Orientationw General UML Modeling Mechanisms

Page 12: Cn if2261 intro tooo

12

Page 12

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 23

R

Stereotypes

w Define a new model element in terms of another model element

w May be applied to all modeling elements

<<boundary>>

<<boundary>>

<<trace>>

Processor #1<<Processor>>

DesignClass

Processor #1

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 24

R

Properties

w A property, or specific attribute, of a UML elementw Also called tagged valuesw Some properties are defined by UML§ Persistence§ Location (e.g., client, server)

w Properties can be created by UML modelers for any purpose

PersistentClass{persistence} anObject : ClassA

{location=server}

Page 13: Cn if2261 intro tooo

13

Page 13

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 25

R

Notes

w A note can be added to any UML elementw It is a ‘dog eared’ rectangle w The note may be anchored to an element with a dashed line

There can be up to one MaintainScheduleForm per user session.MaintainScheduleForm

OOAD Using the UML - Introduction to Object Orientation, v 4.0Copyright 1994-1998 Rational Software, all rights reserved 26

R

Review: Introduction to Object Orientation

w What are the four basic principles of object orientation? Provide a brief description of each.

w What is an Object and what is a Class? What is the difference between them?

w What is an Attribute?w What is an Operation?w What is generalization? w What is polymorphism? w Describe the strengths of object orientation.w Name and describe 3 general UML mechanisms.