Professional Documents
Culture Documents
Design
Using the UML
Version 4.2
Introduction to Object Orientation
Object Orientation
Encapsulation
Abstraction
Modularity
Hierarchy
OOAD Using the UML - Introduction to Object Orientation, v 4.2
Copyright 1998-1999 Rational Software, all rights reserved 4
What is Abstraction?
Salesperso
n
Not saying
Which
salesperso
n – just a
salesperso
n in Product
Customer
general!!!
Manages Complexity
OOAD Using the UML - Introduction to Object Orientation, v 4.2
Copyright 1998-1999 Rational Software, all rights reserved 5
What is Encapsulation?
Hide implementation from clients
Clients depend on interface
Improves Resiliency
OOAD Using the UML - Introduction to Object Orientation, v 4.2
Copyright 1998-1999 Rational Software, all rights reserved 6
What is Modularity?
The breaking up of something complex into
manageable pieces
Order
Entry
Order Processing
System Order
Fulfillment
Billing
Manages Complexity
OOAD Using the UML - Introduction to Object Orientation, v 4.2
Copyright 1998-1999 Rational Software, all rights reserved 7
What is Hierarchy?
Levels of abstraction Asset
Increasing
abstraction
Truck
Conceptual entity
Chemical Process
: Professor
a + b = 10
ProfessorClark
Class Name Only
Professor Clark
ProfessorClark :
Professor Object Name Only
OO Principle: Abstraction
OOAD Using the UML - Introduction to Object Orientation, v 4.2
Copyright 1998-1999 Rational Software, all rights reserved 16
Sample Class
Class
Course
Properties Behavior
Name Add a student
Location Delete a student
a + b = 10
Days offered Get course roster
Credit hours Determine if it is full
Start time
End time
a + b = 10
Professor
Professor Clark
Professor
Professor Jones
OOAD Using the UML - Introduction to Object Orientation, v 4.2
Copyright 1998-1999 Rational Software, all rights reserved 21
Basic Concepts of Object Orientation
Object
Class
Attribute
Operation
Interface (Polymorphism)
Component
Package
Subsystem
Relationships
Object
Class
CourseOffering
Class
addStudent
deleteStudent
getStartTime
Operation getEndTime
Manufacturer B
Manufacturer A Manufacturer C
OO Principle:
Encapsulation
Shape Cube
Canonical Tube
(Class/Stereotype) <<interface>>
Representation Shape
Pyramid
Draw
Move
Scale
Rotate Cube
OOAD Using the UML - Introduction to Object Orientation, v 4.2
Copyright 1998-1999 Rational Software, all rights reserved 29
(stay tuned for realization
Basic Concepts of Object Orientation
Object
Class
Attribute
Operation
Interface (Polymorphism)
Component
Package
Subsystem
Relationships
Uses
Organize the model under development
OOAD Using the UML - Introduction to Object Orientation, v 4.2
<<subsystem>> Component
Component Name Name
Component Component
Interface Interface
Association
Role Names
Class University
Professor
Employee Employer
Student Schedule
Aggregation
Student Schedule
Aggregation
Multiplicity
Navigation
ClientPackage SupplierPackage
Dependency
relationship
OOAD Using the UML - Introduction to Object Orientation, v 4.2
Copyright 1998-1999 Rational Software, all rights reserved 45
Relationships: Generalization
A relationship among classes where one
class shares the structure and/or behavior
of one or more classes
Defines a hierarchy of abstractions in which
a subclass inherits from one or more
superclasses
Single inheritance
Multiple inheritance
Generalization is an “is-a-kind of”
relationship
Account
balance
name
Superclass number
(parent) Withdraw()
CreateStatement()
Generalization
Relationship
Checking Savings
Descendents
OOAD Using the UML - Introduction to Object Orientation, v 4.2
Copyright 1998-1999 Rational Software, all rights reserved 47
Example: Multiple Inheritance
A class can inherit from several other
classes
FlyingThing Animal
multiple
inheritance
Inheritance leverages the similarities among classes
OOAD Using the UML - Introduction to Object Orientation, v 4.2
Copyright 1998-1999 Rational Software, all rights reserved 49
Example: What Gets Inherited
GroundVehicle
owner Person
Superclass weight
(parent) licenseNumber 0..* 1
register( )
generalization
Sale
MyBoundaryClass
<<boundary>>
<<boundary>>
Sample boundary class (stereotype)
<<trace>> Stereotype of ‘dependency relation’
DesignClass Stereotype of <<Processor>>
<<Processor>>
Processor #1 Processor #1
PersistentClass
{persistence} anObject : ClassA
{location=server}
Member 1
Professor Department
1..*
{subset}
Department Head
1 1