details of uml and unified process koichiro ochimizu school of information science jaist
TRANSCRIPT
Details of UML and Unified Process
Koichiro OCHIMIZU
School of Information Science
JAIST
Use-Case View
Use-CaseView
ConcurrencyView
LogicalView
DeploymentView
ComponentView
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Use Case Model
Use Case Model : A use case model represents the functional requirements and consists of actors and use cases. A use case model helps the customer, users, and developers agree on how to use the system.
Actor: An actor is someone or something that interacts with system.
System: Black box provided with use cases
Use Case: A use case specifies a sequence of actions that the system can perform and that yields an observable result of value to a particular actor.
I. Jacobson, G.Booch, J.Rumbaugh,”The Unified Software Development Process”, Addison Wesley, 1999.
Development of Use Case Model
• Defining the System• Finding Actors and Uses Cases• Use Case Descriptions• Defining Relationships between Use
Cases• Verify and Validate the Model
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
What is an Actor ?• An actor is someone or something that Interacts
with the system.• The actor is a type ( a class), not an instance.• The actor represents a role, not an individual user
of the system.• Actors can be ranked. A primary actor is one that
uses the primary functions of the system. A secondary actor is one that uses secondary functions of the system, those functions that maintain the system, such as managing data bases, communication, backups, and other administration tasks.
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Finding Actors• Who will use the main functionality of the system ?• Who will need support from the system to do their
daily tasks ?• Who will need to maintain, administrate, and keep
the system working (secondary actor) ?• Which hardware devices does the system need to
handle ?• With which system does the system need to interact ?• Who or what has an interest in the result (the value)
that the system produce ?
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
What is a Use Case ?• A use case represents a complete functionality as
perceived by an actor.• A use case is always initiated by an actor.• A use case provides values to an actor.• A use case is complete.• Use cases are connected to actors through
associations (communication association).• A use case is a class, not an instance. A
instantiation of a use case is called a scenario.– Signing Insurance (Use Case)
– John Doe contacts the system by telephone and signs for car insurance for the Toyota Corolla he just bought. (scenario)
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Finding Use Cases
• Which functions does the actor require from the system ? What does the actor need to do ?
• Does the actor need to read, create, destroy, modify, or store some kind of information in the system ?
• Does the actor have to be notified about events in the system, or does the actor need to notify the system about something ? What do those events represent In terms of functionality ?
• Could the actor’s daily work be simplified or made more efficient through new functions in the system ?
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Logical View
Use-CaseView
ConcurrencyView
LogicalView
DeploymentView
ComponentView
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
A Simple model of an insurance business
Insurancecompany
Insurancecontract
Customer1 0..* 0..* 1..*
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Finding Classes• Do we have information that should be stored or analyzed?
If there is any information that has to be stored, transformed, analyzed, or handled in some other way, then it is a possible candidate for a class. The information might be concepts that must be always be registered in the system or events or transactions that occur at a specific moment.
• Do we have external system ? If so, they are normally of interest when we model.
• Do we have any patterns, class library, components ? If we have them from earlier projects, colleagues, or manufacturers, they normally contain class candidates.
• Are there devices that system must handle ?• Do we have organizational parts ?• Which roles do actors in the business play ? There roles can be
seen as classes; for example, user, system operator, customer, and so on.
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Visibility
• + public referenced from classes other than the one in which they are defined– It violates Information hiding principle
• - private cannot access it from other classes• # protected can access it from sub classes
Invoice
+ amount : Real+ date : Date+ customer : String+ specification : String- administration : String
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Default values
• Assigned at the same time an object of the class is created
Invoice
+ amount : Real+ date : Date = Current date+ customer : String+ specification : String- administration : String = “Unspecified”
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
A class-scope attribute or a class variable
• A class variable (underlined) is shared by all objects of the class
Invoice
+ amount : Real+ date : Date = Current date+ customer : String+ specification : String- administration : String = “Unspecified”- number of invoices : Integer
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Property string
• Property string show the possible values explicitly
Invoice
+ amount : Real+ date : Date = Current date+ customer : String+ specification : String- administration : String = “Unspecified”- number of invoices : Integer+ status : Status = { unpaid, paid}
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Java implementation
public class Invoice{ public double amount; public Date date = new Date(); public String customer; static private int number_of_invoices = 0;
// Constructor, called every time an object is created public Invoice() { // Other initialization number_of_invoices++; Increment the class attribute } // Other methods go here};
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Signature
• Signature: a return-type, a name, zero or more parameters
Car
+ registration number : String- data : CarData+ speed : Integer+ direction : Direction- administration : String
+ drive(speed: Integer, direction: Direction)+ getData(): CarData
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Class-scope operation
• Access class-scope attributes• Creation of objects
Figure
size : Sizepos : Positionfigcounter : Integer
draw() getCounter(): Integer
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Visibility of Operation
Figure
size : Sizepos : Position
+ draw()+ scaleFigure(percent: Integer = 25)+ returnPos(): Position
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Default values of parameter
• figure.resize(10,10) percentX=10, percentY=10
• figure.resize(37) percentX=37, percentY=25
• figure.resize() percentX=25, percentY=25
Figure
size : Sizepos : Position
+ draw()+ resize(percentX: Integer = 25, percentY: Integer = 25)+ returnPos(): Position
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Java implementation
Figure
- x: Integer = 0- y: Integer = 0
+ draw()
Figure fig1 = new Figure();Figure fig2 = new Figure();fig1.draw();fig2.draw();
public class Figure{ private int x = 0; private int y = 0;
public void draw() { // Java code for drawing the figure }};
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
UML notationsRepresentation of Relationships between Classes
Dependency
Navigable Association
Association
Generalization
Aggregation: whole-part association
Composition: the same life span
G.Booch, J.Rumbaugh, I. Jacobson , ”The Unified Modeling Language User Guide”, Addison Wesley, 1999.
Multiplicity
Person Car0..*1..*
Person Car0..*owns
owned by
owns
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
A class diagram describing an Insurance business
Customer
1..*
Insurance Policy
0.. 1
Insurance contract
InsuranceCompany
1
1
0..*
0..*
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Computername: String
memory: Integer
0..* 1..*Authorname: Stringage: Integer
Use
Bob’s PC: Computer
name = “ Dell466”memory = 64
Bob:Author
name = “Bob J”age = 32
Object Diagram
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Recursive Association
Node
Connects
*
*
Person
married to
wife
husband
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Component
Operation()Add(Component)
Remove(Component)GetChild(int)
Composite
Client*
Leaf
Operation()
E.Gamma, R.Helm, R.Johnson, J.Vlissides,”Design Patterns”, ADDISON-WESLEY, 1995.
Clients use the Component class interface to interact with objects in the composite structure. If the recipient is a Leaf, then the request Is handled directly. If the recipient is a Composite, then it usually forwards requests to its child components, possibly performing additional operations before and/or after forwarding.
CompositeOperation()
Add(Component)Remove(Component)
GetChild(int)
forall g in children
g.Operation()
children
Object Diagram
aComposite
aCompositeaLeafaLeaf
aLeafaLeafaLeaf
aLeaf
E.Gamma, R.Helm, R.Johnson, J.Vlissides,”Design Patterns”, ADDISON-WESLEY, 1995.
Java Implementation
// Insurance_company.java filepublic class Insurance_company{ /* Methods */// Insurance_companyVector is a specialization of the // Vector class ensuring hard typing. Vector is a standard// Java class for dynamic arrays. private Insurance_contractVector contracts;};
// Insurance_contract.java filepublic class Insurance_contract { /* Methods */ private Insurance_company refer_to};
InsuranceContract
InsuranceCompany
1 0..*
refers to
contracts
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Qualifier
Figure*Canvas
FigureCanvasfigure ID
“one to many” to “one to one
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
OR-association
Person Company
0..*Insurancecontract
Insurance company
1
0..
0..*
1..*1..*
Person Company
0..*Insurance contract
Insurancecompany
1
0..
0..*
1..*1..*
{or}
An insurance contract cannot have associations to both company and person at the same time
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Ordered Association
Insurance contract
0..*
1..*
{ ordered }
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Customer
Association Class
ElevatorControl
Button
Elevator
Queue
*
3
A class can be attached to an association
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
The association class is not connected at any of the ends of the association
Ternary Association
Person
Insurancepolicy
Insurancecontract
Insurance company
1 0..*
1..*
0.. 1
0..*
policyholder
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
What is an Aggregation ?
• Aggregation is a special case of association• “whole-part”, “is-part-of”• Special kinds of aggregation
– aggregation
– Shared Aggregation
– Composition Aggregation
Aggregation
Composition: The part has the same life span with the whole
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Aggregation
Warship*Navy
This example is not so good.
Contains
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Shared Aggregation
PersonTeam
A team is composed of team members.
One person could be a member of many teams.
Members
**
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Composition Aggregation
Window
*
*
*
Text
Listbox
Button
Menu
*
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Another Expression of Aggregation
Window
*
*
*
*
Text
Listbox
Button
Menu
Text
Listbox
Button
Menu
Window
*
*
*
*
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Generalization
• Associations and Aggregation describe structure of the problem domain which we are interested in.
• Generalizations describe concepts which are common to several problem domains.
Property
(reusability)
Problem Fitness
Vehicle
Car Boat
Generalization and Association
stockproblem domain2
class drawer{ }
class stock{ }This yearApril
drawer
purse drawer money stock
A BProblemdomain3
class A extend{ }
class B extend{ }Next year
purse moneyproblem domain1
class purse{ }
class money{ }Last yearMay
container content
A B
Inheritance
• Class inheritance
• Interface Inheritance
Combination of Inheritance and Aggregation
Figure{abstract}
position: Posdraw(){abstract}
Canvas
Circle
draw()
Line
draw()
Group
draw()
Polygon
draw()
consists of
*
consists of *
consists of *
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Java Implementation
Figure{abstract}
position: Posdraw(){abstract}
Group
draw()
Polygon
draw()
*
abstract public class Figure{ abstract public void draw(); protected Pos position;};
public class Polygon extends Figure{ public void draw(); { /* draw polygon code */ }};
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Constrained Generalization
Class A
Class B Class C
{constraint1, constraint2, … ,}
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Overlapping
Disjoint
Complete
Incomplete
Overlapping and Disjoint
Vehicle
Car Boat
Amphibian
{overlapping}
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Complete and Incomplete
Person
Man Woman
{Complete}
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Refinement relationship
AnalysisClass
Design Class
• A refinement is a relationship between two descriptions of the same thing, but at different levels of abstraction.
• It can be also used to model different implementations of the same thing.
• Support Configuration Management.
• Support traceability In the model.
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Derivation
Car hirecompany
• can be computed from other associations and attributes.
• The VIP customers are a derived association when company makes contracts with many customers.
Hire contract
Customer
0..*
1
1
0..*
*
/ VIP customer
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Derived Attribute
Article
cost pricesales price
/profit
{ profit = sales price – cost price }
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Subset Constraint
Politician Party
1..* 1
1 1
Member of
Party leader of
(subset}
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Navigation Expression
• set.Attribute • set.role• set ._~role• set{ boolean expression } • set.[ qualifier value }
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Template
Array<Car,100>Array
T, n:integer
Color Array
<<bind>><Color,50>
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Parameterized class
Dynamic Model
• State Diagram– Describe which states an object can have during its life cycle
• Sequence Diagram– Describe how objects interact and communicate with each other
– The primary focus in sequence diagrams is time
• Collaboration Diagram– Describe how objects interact
– But the focus in a collaboration diagram is space
• Activity Diagram– Describe how objects interact
– But the focus in an activity diagram is work
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Object Interaction( Message )
• Synchronous– procedure call or other nested flow of control
• Return– return from a procedure call
• Simple– Flat flow of control
• Asynchronous– Asynchronous flow of control.
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Defining behavior of the system by a state diagram
Process Control System
Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan
What is a State ? on init help ! timeout
time
Frozen Frozen Frozen Frozen Frozen Period 1 Period 2 Period 3 Period 4 Period 5
Not inOperation
Poweron
Monitoring ControllingAlarm
on
on/Action init/Action help/Action timeout/Action
Success of control/action
Ochimizu, Higashida, ”Object Modeling”,
Addison-Wesley Publishers Japan
State Model
• Represent the behavior of an object by a state transition diagram.
Defining the behavior of philosopher and fork
Each philosopher must use right next fork and left next one not used
right-next
left-next
philosopher forkuse
0..20..1
Ochimizu, Higashida,”Object Modeling”, Addison-Wesley Publishers Japan
Behavior of a Philosopher
thinking
eating
thinking end/
takes forks
eating end/
put down forks
Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan
State transition depends on the state of forks both side
State 1 State 2
Event [guard] / action
Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan
Detailed behavior of a philosopher
having a forkat left hand
having a forkat right hand
[left-next fork is not used]/take a fork at left hand
[left-next fork is not used]/take a fork at left hand
[right-next fork is not used]/take a fork at right hand
[right-next fork is not used]/take a fork at right hand
[forks at both side are not used]/take forks at both hands
/put down forks
waiting
thinking
eating
having two forks
Ochimizu, Higashida, ”Object Modeling”,
Addison-Wesley Publishers Japan
Passive Object and Active Object
• Passive Object– It is activated when it receives a message from other
object ( work when being hit)
• Active Object– It can change its state by itself and send a message to
other object if necessary
• In the case of philosopher– Philosopher’s state of hunger changes autonomously
during thinking and eating.
Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan
Simplified behavior
eating
thinking
having a forkat left hand
having a forkat right hand
Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan
[left-next fork is not used]/take a fork at left hand
[right-next fork is not used]/take a fork at right hand
[right-next fork is not used]/take a fork at right hand
[left-next fork is not used]/take a fork at left hand
[forks at both side are not used]/take forks at both hands
/put down forks
Defining the behavior of a fork
not used
used
take / takenput down / put down
Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan
Class Diagram
left-next
philosophername
right handleft hand
take at right handtake at left hand
take at both handput down both
forkname
state of useput
taken
use
right-next
0..20..1
Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan
Execution
p2
p3
p4
p5
p1 f1
f2
f3
f4
f5
right-next
right-next
right-next
right-next
right-next
left-next
left-next
left-next
left-next
left-next
use
use
Ochimizu, Higashida, ”Object Modeling”,
Addison-Wesley Publishers Japan
Initial State and Final State
Unpaid Paidpaying
Invoice created
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Invoice destroyed
A state diagram for an elevator
On first floor
idle
Moving up
time-outgo down
arrived
go up
go up
Moving down
Moving to first floor
arrivedarrived
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
State Transition
State 1do : activity1
State 2event-signature [guard]/action ^send-clause
event-signature: event-name (parameter list)
draw (f: Figure, C: color)
draw()send-clause: destination-expression . Destination-event-name (argument list)
message sent during transition
[timer=time-out] ^ self.go down ( first floor )
destination-expression: object or a series of objects
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Guard
J .Rumbaugh,”Object-Oriented Modeling and Design”, PrenticeHall,199.
East/westmay turn right
time-outtime-out
Time-out [cars in N/S right lanes] North/south
may turn rightNorth/southmay go strait
Time-out [no cars in N/S right lanes]
Time-out [cars in E/W right lanes]
East/westmay go strait
Time-out [no cars in E/W right lanes]
State Generalization
ThirdSecond
Reverse
First
Neutral
push F
push N
push R
push N
stop upshift upshift
downshiftdownshift
Automatic transmission
Forward
J .Rumbaugh,”Object-Oriented Modeling and Design”, PrenticeHall,199.
Automatic Transition
idleCollecting money
coins in (amount)/add to balance
do: test item and compute change
do: dispense item do: make change
coins in (amount)/set balance
cancel/refund coins
select (item)[item empty] [change<0]
[change>0][change=0]
J .Rumbaugh,”Object-Oriented Modeling and Design”, PrenticeHall,199.
Sub diagram
Do: move armto correct row
do: move armto correct column
do: push item off shelf
arm ready
arm ready
dispense item
J .Rumbaugh,”Object-Oriented Modeling and Design”, PrenticeHall,199.
A state diagram for an elevator
On first floor
idletimer = 0
do: increase timer
Moving updo:moving to floor
[timer=time-out]go down (floor)
arrived
go up (floor)
go up
Moving downdo: moving to floor
Moving to first floor
arrivedarrived
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Events in the state diagram correspond with operations within the class
Displaydo/ display
current time
Set hoursdo/ display
hours
Set minutesdo/ display
minutes
mode~button
mode~button mode~button
inc/minutes:=minutes+1 modulo 60
inc/hours:=hours+1 modulo 24
Digital~watch
mode-button() inc()
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Four types of events• Guard (Condition) becomes true.• Receipt of an explicit signal from another
object– The signal itself an object– This type of event is called a message
• Receipt a call on an operation by another object (or by the object itself).– This type of event is also called a message
• Passage of a designated period of time.– This is shown as a time-expression on state transitions.
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
An event is an object too
<<signal>>Input
{abstract}device: Device
time: Time
<<signal>>Right Mouse
Button
<<signal>>Voice Recognition
commando : String
<<signal>>Keyboard
character:Charup: Boolean
down: Boolean
<<signal>>Mouse
{abstract}up: Boolean
down: BooleanxPos: intyPos: int
<<signal>>Left Mouse
Button
IdleSend
do / send(input)to corresponding
class
input
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
A state diagram for digital watch
Displaydo/ display
current time
Set hoursdo/ display
hours
Set minutesdo/ display
minutes
mode~button
mode~button mode~button
inc/minutes:=minutes+1 modulo 60
inc/hours:=hours+1 modulo 24
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Java program for digital watch (1/2)
public class State{ public final int Display = 1; public final int Set_hours = 2; public final int Set_minutes = 3; public int value;};
public class Watch{ private State state = new State(); private DigitalDisplay LCD = new DigitalDisplay(); public Watch() { state.value = State.Display; LCD.display_time(); }
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
public void mode_button() { switch ( state.value) { case State.Display: LCD.display_time(): state.value = State.Set_hours; break; case State.Set_hours: LCD.display_hours(): state.value = State.Set_minutes; break; case State.Set_minutes: LCD.display_minutes(): state.value = State.Display; break; } }
public void inc() { switch ( state.value) { case State.Display: : break; case State.Set_hours: LCD.inc_hours(): break; case State.Set_minutes: LCD.inc_minutes(): break; } }}
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Java program for digital watch (2/2)
Message passing between two state diagram
On/Play
Play ()
Stop ()
Off() / Stop ()
Off On/Stop
On ()
Off ()
Off On
Off ()
CD Player
Remote ControlOn ()
On () Off ()
Play ()
Play ()
Stop ()
Stop ()
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Or-substate and And-substate
Or-substate
And-substate
Running
Running
Forward Backward
Low speed High speed
Forward Backward
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
History Indicator
• is used to memorize internal state• Support roll-back• If a transition to the indicator fires, the object
resumes the state it had last within that region• Shown as a circle with an H
H
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Sequence Diagram• Sequence diagrams illustrate how objects
interact with each other.• They focus on message sequences, that is, how
messages are sent and received between a number of objects.
• Sequence diagrams have two axes: the vertical axis shows time and the horizontal axis shows a set of objects.
• The Instance form describes a specific scenario in detail
• The Generic form describes all possible alternatives in a scenario, therefore branches, conditions, and loops may be included.:
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
: Computer: Printer
Server: Printer
The Concepts used In a sequence diagram
Print( ps-file)
Print( ps-file) [no queue] Print( ps-file)
Simple message
Activation
Lifeline
Synchronous message
Object
Guard
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
: Computer: Printer
Server
Sequence diagram with BranchPrint( ps-file)
Print( ps-file)
: Printer : Queue
[no queue] Print( ps-file)
[printer busy] Store( file)
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
: Computer: Printer
Server
Timing Constraint
Print( ps-file)
Print( ps-file)
: Printer
Print( ps-file){ b - a < 5 sec}
{ b’- b < 1 sec }
a
b
b’
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
C1 : C D1:D
Iteration
D2:D
send message op2 until ...
op1 ()
op2 ()
op3 ()
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
: CustomerWindow
D1:D
Creating Object
NewCustomer(Data)
Customer (Data)
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
: CustomerWindow D1:D
Destroying Object
RemoveCustomer()
DeleteCustomer ()
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
object name
: class
Recursion
oper()
oper()
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Collaboration Diagram
• Collaboration diagrams focus on the interaction and the links between a set of collaborating objects. The sequence diagram focuses on time but the collaboration diagram focuses on space.
[printer free] 1.1: Print(ps-file)
1 : Print(ps-file)
Print(ps-file)
An example of a collaboration diagram
:Computer
:PrinterServer :Printer
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Message Labelpredecessor guard-condition sequence-expression return-value := signature
sequence-number , … /
The predecessor is an expression for synchronization of threads or paths, meaning that the messages connected to specified sequence-number must be performed and handled before the current message is sent.[ integer | name | recurrence] ・ integer a sequence-number specifying the message order 1.2.1 ・ name concurrent thread of control 1.2a 1.2b ・ recurrence * [ iteration-clause] [ condition-clause]
a conditional or iterative exrcution
1 : display() [mode = display] 1.2.3.7: redraw() 2 * [n:=1..z]: prime:=nextPrim(prim)3.1 [ x < 0 ] : foo()3.2 [ x => 0 ] : bar()1.1a, 1.1b/ 1.2: continue()H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
1 * [ z = 1..n ]: prim:=nextPrim(prim)
CalcPrim (n)
Iteration in a collaboration diagram
:Calculator
:Prim module
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Elevator Control
: Button
: Elevator control
: Queue
: Order{new}
: Elevator
Push()
1.1 *[all queues]:len=Length(){broadcast}
1.3: invoke(job)
1.2: Create()
job1:GetElevator(floorid)
2:nextjob=GetJob()
{parameter}job
{local}nextjob
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Constraints for link role• Global: specify that the corresponding
instance is visible because it ‘s in a global scope• Local: specify that the corresponding instance
is visible because it’s a local variable in an operation.
• Parameter: specify that the corresponding instance is visible because it’s a parameter in an operation.
• Self: specify that an object can send messages to itself
J. Rumbaugh, I. Jacobson, G. Booch, The Unified Modeling Language Reference Manual, Addison-Wesley
A state diagram for an elevator
On first floor
idletimer = 0
do: increase timer
Moving updo:moving to floor
[timer=time-out]go down (floor)
arrived
go up (floor)
go up (floor)
Moving downdo: moving to floor
Moving to first floor
arrivedarrived
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Customer Window creation
: CustomerWindow {transient}
: Mainwindow : Customer{new}
Newcustomer()
3.1: Update(data)
2: Create()
3:Show(customer)
[free memory] 1:Create()
{parameter}
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
1: Show()
1.1: Create()
3:Show(customer)
1.2 *[while any lines left]: GetResultLine()
1.1.1 *[for all salespersons]: ordersum = GetTotalOrderSum() 1.1.2 *[for all salespersons]: budget = Getbudget()
: SalesPerson
: StatisticsSummary
{new}
: Sales StatisticsWindow
: Order
: Budget Sales
1.1.1.1 *[for all orders]: GetOrderAmount()
1.1.2.1 : GetBudgetAmount()
Summarizing sales results
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Exercise
1: f1 ( )
1.1: f2 ( )1.2: f3 ( )
1.1.1: f4 ( ) 1.1.2: f5 ( )
: C3: C2: C1
: C5
: C4
1.1.1.1: f7 ( )
1.1.2.1 : f6 ( )
Answerf1( )
f2 ( )
f3 ( )
f7 ( )
f6 ( )
: C1 : C2 : C3 : C4 : C5
f4 ( )
f5 ( )
call
return
UML Ver.1.3
1 1.1 1.1.1 1.1.1.1 1.1.2 1.1.2.1 1.2
Activity Diagram
• An activity diagram is essentially a flowchart, showing flow of control from activity to activity
Actions and Transitions
Show messageBox
“Printing” onscreen
CustomerWindow.PrintAllCustomer()
Create postscriptfile
Send postscriptfile to printer
RemoveMessageBox
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Transition with send-clause
Show messageBox
“Printing” onscreen
CustomerWindow.PrintAllCustomer()
Create postscriptfile
RemoveMessageBox
^Printer.Print(file)
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Transitions are protected by guarded-conditions
CustomerWindow.PrintAllCustomer()
Create postscriptfile
RemoveMessageBox
^Printer.Print(file)
[disk full]
Show messageBox
“Disk full” onscreen
Show messageBox
“Printingl” onscreen
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Parallel Actions
.Sampler.Run(channel,frequency)
Initiate
Updatingdisplay
Measuring
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Swim lanes
.Sampler.Run(channel,frequency)
Initiate
Updatingdisplay
Measuring
Displayer Sampler
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Object Flow
.Sampler.Run(channel,frequency)
Initiate
Updatingdisplay
Measuring
Displayer Sampler
Measuredvalue
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Sending/receiving signals.Sampler.Run(channel,frequency)
ShowMessageBox
“Printing” onscreen
RemoveMessageBox
Print file
aPrinter: Printer
Create postscriptfile
Print(file)
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Concurrency View
Use-CaseView
ConcurrencyView
LogicalView
DeploymentView
ComponentView
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Specific Features of Real-time Systems
• Timeliness is important. The system performs its function within specified time limits.
• Reactive. The system is continuously responding to events from the external environment that “drives” the execution of the system.
• Concurrently executing threads of control, where different parts of the software run in parallel.
• Very high requirements on most of the nonfunctional requirements such as reliability, fault tolerance, and performance.
• Not deterministic
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Basic Concepts for real-time system modeling
• time requirement• asynchronous event handling• communication• concurrency
– process, thread
• synchronization
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Concurrency in Object-Orientation
• Explicit concurrency model– Explicit concurrency model describes concurrency separately from the objects by
defining processes at an early stage of analysis, and then treating processes and objects as separate modeling entities. The system is decomposed into a number of processes, and each process is internally modeled as an object-oriented system to design the internal structure.
• Implicit concurrency model– Implicit concurrency model delay the design of concurrency. The system is modeled
as objects, where in an early analysis, all objects are considered to have their own execution threads; that is, be active objects. Gradually, through architecture and detailed design, the ideal analysis models are mapped onto an implementation with the support of services from the underlying real-time operating system.
• UML can support both – It has better support for the implicit concurrency model. Active classes,
asynchronous communication, and synchronization can be modeled in early phases and gradually be translated into the services and capabilities of the implementation environment.
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Active Class and Object
An active class is a one that owns an execution thread and can initiate control activity
Active Class Active Object
<<Active Class>Communication
Supervisor
aninstance :Communication
Supervisor
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
An active object with its internal structure
:Communication Supervisor
:CommManager
Port1:Communication
Port
Input:MessageBuffert
Output:MessageBuffer
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Thread of Control
• Thread: Thread of control– A sequence of control transfer in a program
• Multi Threads– Multiple threads exist together in a program
and they can run concurrently
S. Oaks, H. Wong, “Java Threads”, O’REILLY, 1997.
• public class OurClass {• public void run() {• for(int i = 0; i < 100; i++) {• System.out.println(“Hello”);• }• }• }Import java.applet.Applet;public class OurApplet extends Applet{ public void init() { ourClass oc = new OurClass(); oc.run(); }}
The run() method that writes a string 100 times to standard output is defined in OurClass
This example simply shows a method invocation as shown in the left figure.Execution of Applet thread
Applet executes init()
Applet executes run()
t
Thread using Thread class
Applet thread works by executing run() method in Applet
S. Oaks, H. Wong, “Java Threads”, O’REILLY, 1997.
Execute run() method of OurClass concurrently with init() or the other
Applet methods • public class OurClass extends Thread{• public void run() {• for(int i = 0; i < 100; i++) {• System.out.println(“Hello”);• } }}
Import java.applet.Applet;public class OurApplet extends Applet{ public void init() { ourClass oc = new OurClass(); oc.start(); }}
Implementation of start() method is in a Thread class or its super class
start() method invokes run() method directly or indirectly.
start() method creates the new thread of control
S. Oaks, H. Wong, “Java Threads”, O’REILLY, 1997.
Methods of the Thread class
• Thread() : creates a thread object using default values for all option
• void run() : the method that is executed by the newly created thread. It can be considered as a main() of the newly created thread. This method should be over-ridded by the code that is executed by the new thread.
• void start() : creates a new thread and executes run() method that is defined in this thread class
new creation of an instance
sleep sleep
start enqueue it to the thread queue
run public void run() { if (target != null) { target.run(); }}
Default run() method of a Thread object
S. Oaks, H. Wong, “Java Threads”, O’REILLY, 1997.
States of an active object
Ready WaitingRunningSchedule Making Call
TerminateCreate
Running time > 50 msec
Result of call
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Run-time environment view of threads
channel
main memory
CPU
pc
channel
register
run() {
}
thread 1
thread 2
createrestore
Running
Readysave
Waiting or Ready
Ready
restore
Waiting or Ready
Running
restoreRunning
Waiting or Ready
t
Applet thread executes the other task
Applet executes init() method
Applet executes internal task thread
Applet executes the start() method
Applet executes its run() method
stop
S. Oaks, H. Wong, “Java Threads”, O’REILLY, 1997.
Execute run() method of OurClass concurrently with init() or the
other Applet methods
• public interface Runnable{• public abstract void run();• }• public class OurClass implements Runnable{• public void run() {• for(int i = 0; i < 100; i++) {• System.out.println(“Hellow”);• } }}
S. Oaks, H. Wong, “Java Threads”, O’REILLY, 1997.
Thread using Runnable Interface
Runnable interface only have a run() method
Import java.applet.Applet;public class OurApplet extends Applet{ public void init() { Runnable ot = new OurClass(); Thread th = new Thread(ot); th.start(); }}
Communication among active objects• Operation call
– An ordinary call of an operation. A caller waits for the operation to finish and return
• Mailboxes/Message queues– This technique allows for asynchronous message
• Shared memory– Two or more active objects can write and read information from/to a block
of memory reserved for communication. The block has to be guarded by some kind of synchronization mechanisms.
• Rendezvous– Specific points in the execution of two threads are defined. The first thread
to reach Its rendezvous point stops and waits for the other thread to reach its corresponding rendezvous point. When both threads are at the rendezvous point, they exchange information and then start to execute concurrently again.
• Remote procedure calls (RPCs)– RPCs handle distribution of the concurrent threads to separate computers in
a network.
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Events
• In a real-time system, events are drivers of system activity• An event is something that occurs in the system or in the
environment.• All events that can occur must be defined; furthermore,
the behavior of the system when the event happens must be defined.
• In UML, there are four different categories for events:– A condition (guard) become true– The receipt of an explicit signal object– The receipt of an operation call– A passage of time
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Signals
• Signals are defined in UML as “a named event that can be raised
<<signal>>MouseMove
<<signal>>Key
Pressed
<<signal>>ObjectDrop
<<signal>>Perform
Command
<<signal>>Signal
{abstract}
<<signal>>Physical
{abstract}
<<signal>>Logical
{abstract}
<<signal>>Synchronization
{abstract}
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Synchronization
• Concurrent processes interact with each other– to exchange data– to share resources, referring variables that show the status of the resource
• It cause the occurrence of time-dependent errors• Synchronization mechanisms are required to avoid errors.
– Mutual exclusion: operation A and operation B should be executed exclusively
– Message buffer: A producer of data can not send data more than the finite capacity of a buffer. A consumer of data can not receive data before it is produced.
– Exchange of timing signals: semaphore invariance– 0 <= r(v) <= s(v) + c(v) <= r(v) + max(integer)– s(v): number of signals sent, r(v): number of signals received, c(v): initial
value of signals, max: maximum countable number of a counter
Problems without synchronization
• The problems that can occur if synchronization is not properly handled– incorrect shared access: use mutual exclusion between
the thread– inefficient resource usage: avoid busy-wait– dead locks: detection, protection, resolution– starvation: thread scheduling
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Message Buffer
The position to be written next
The position to be read next
empty
full
synchronization rule
(1) A consumer can not receive the message before the message is sent
0 <= r < s
(2) A producer can not put the new message into the position before the message In the position is read
0 <= s - r < max
The pointer P can not pass the pointer C and the pointer C can not pass the pointer
P (a producer)C ( a consumer)
Synchronization Supports in UML
• sequential– The class/operation is intended only for use in a single thread of
control
• guarded– The class/operation will work in the presence of multiple threads
of control. The threads normally have to lock the object/operation before using it, and unlock it afterward.
• synchronized– The class/operation will work in the presence of multiple threads
of control; the class itself handles this. Operation can be declared as synchronized.
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Scheduling
• Scheduling is the process of deciding which thread should run next in a situation where several threads are conceivable
• Scheduling is done by the operating system, which allocates the processor to a thread using some predefined algorithm (e.g. round-robin)
• In a complex situation where detailed control is needed of the scheduling, a supervisor thread can be designed.
• In UML, the priority of an active object is most suitably noted as a tagged value of the active class
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Implementation of Concurrency and Synchronization in Java
class DemoThread extends Thread{ public void run() { try{ for ( ; ; ) {// Do forever // Synchronous message to System.out object system.out.println(“Hello”); // Asynchronous message placed in Global_mailbox // Needs definition of class Signal and Mailbox // elsewhere. Signal s = new Signal(“Asynch Hello”); Global_mailbox.Put(s); Sleep(10); // Waits for 10 milliSeconds. } } catch ( InterruptedException e) { } } public static void main(String[ ] arg) { // Create an instance of the active class (thread) DemoThread t1 = new DemoThread(); t1.start(); // Start execution // Create another instance of the active class DemoThread t2 = new DemoThread(); t2.start(); // Start execution }}
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Basic Mechanisms for Modeling Real-time Systems in UML
- house alarm system -
• Time: time specifications and c onstraints are best defined in sequence diagrams
• Concurrency: is described as active classes• Asynchronous event: asynchronous message• Synchronization: c an be described either as properties of
classes or operations( concurrency properties) or as classes/stereotypes that define mechanism such as a semaphore, monitor, or critical region.
• Distribution: Thread deployed in a distributed system are described in a deployment diagram.
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Sensors
<< ActiveClass >>Sensor
{abstract}+ id : Address
SelfTest()Activate()
DeActivate()
Photo CellSensor
DevicSpecificConfiguration
parametersSelfTest()Activate()
Deactivate()
HeatSensor
DevicSpecificConfiguration
parametersSelfTest()Activate()
Deactivate()
SoundSensor
DevicSpecificConfiguration
parametersSelfTest()Activate()
Deactivate()
Messages sentfrom a sensordevice is ACKor NAK or an alarm signal
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Alarms
<< ActiveClass >>Alarm
+ id : AddressSelfTest()
Trigger ()TurnOff()
PhoneAlarm
DevicSpecificConfiguration
parametersSelfTest()
Trigger ()TurnOff()
LightAlarm
DevicSpecificConfiguration
parametersSelfTest()
Trigger ()TurnOff()
SoundAlarm
DevicSpecificConfiguration
parametersSelfTest()
Trigger ()TurnOff()
Messages sentfrom an alarmdevice is ACK
or NAK
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
A hierarchy of signal classes
<<signal>>Signal
{abstract}timeSent: Time
sender: ObjectID
<<signal>>Trigger
<<signal>>ACK
<<signal>>NAK
<<signal>>Alarm
<<signal>>Turnoff
<<signal>>General Signals
{abstract}
<<signal>>Sensor Signals
{abstract}
<<signal>>Alarm Signals
{abstract}
<<signal>>Error
<<signal>>Activate
<<signal>>Deactivate
<<signal>>Heartbeat
<<signal>>SelfTest
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Class diagram
Supervisor
SoundAlarm
Log
LCD DisplayWrapper
KeyboardHandlerWrapper
System Handler
Cell Handler
Sensor
Alarm
1..*
1..*
<<persistent>>Cell
ConfigurationInformation
<<persistent>>System
ConfigurationInformation
1
11
1
1 1
1..*
1..*
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Collaboration diagram
: Supervisor
: SoundAlarm
: Log
: System Handler
:Cell Handler
:Photo Cell Sensor
1. Alarm
:PhoneAlarm
:SoundAlarm
2a. Trigger2b. Trigger
2c. Alarm2c.1 Store (Date, Time, Cell, Sensor)
2c.2 Trigger
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Sequence diagram
:SystemHandler
:CellHandler
:Sensor :Alarm :Cell
ConfigurationInformation
Read Configuration
Config info returned
Activate
Activate
SelfTest
SelfTest
ACK
ACK
ACKACK
A
B
B - A < 5 sec
Repeat for each installed alarm and sensor
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
State diagramActivation Phase
PerformingAlarm
SelfTest
PerformingSensor
SelfTest
Activatingsensordevice
Creatingdevice list
InitiatingThread loop
SystemActivated
ActivationFailure
/ send ACK
/ send ACK
SelfTest
SelfTest
Activate Command /Send ACK
createList built
success
NAK NAK
NAK
Alarms
Sensors
Cell Handler
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Control flows are divided into concurrent threads that run in parallel and later become synchronized again
ActivatingSensors
ActivatingAlarms
InitiatingCell Handler
SystemInactive
SystemActivated
ActivationFailure
“Activate System” command
/ Green light on
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
The run operation defined for the active Cell Handler class
Waiting forSignal
Documentedin separate
activitydiagrams
Report to System
Alarm(to system handler)
Heartbeat( to system handler)
TriggerAlarm
Order time-out signal from real-time OS
Alarm Activate Deactivate Time-out
ActivateMessageHandling
DeactivateMessageHandling
Time-outMessageHandling
TriggerAlarm A
TriggerAlarm B
TriggerAlarm X
H.E. Eriksson and M. Penker,
“UML Toolkit” John Wiley & Sons, Inc.
The deployment diagram for the house alarm system
<<Thread>>Cell
Handler
<<Thread>>Alarm
<<Thread>>Sensor
<<Thread>>AlarmSystem
Handler
User Panel
Alarm
1 11
1
1..*
1..*
Sensor
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
The UML definition of architecture
• Architecture is the organizational structure of a system
• An architecture can be recursively decomposed into – parts that interact through interfaces– relationships that connect parts– constraints for assembling parts
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Logical Architecture and Physical Architecture
• Logical Architecture– The logical architecture deals with the functionality of the system,
allocating functionality to different parts of the system and specifying in detail how the solution work.
– In UML, the diagram used to describe the logical architecture are usecase, class, state, activity, collaboration, and sequence.
• Physical Architecture– The physical architecture deals with a detailed description of the system,
in terms of the hardware and software that the system contains. It reveals the structure of the hardware, including different nodes and how these nodes are connected to each other. It also illustrates the physical structure and dependencies of the code modules that implement the concepts defined in the logical architecture; and distribution of the run-time software in terms of processes, programs, and other components.
– In UML, the diagram used to describe the physical architecture are component and deployment
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Allocating Components to Nodes• Class and collaborations as defined in the logical design are allocated to
components in which they are implemented. The allocation is driven by the programming language used. Java implements a class in just one file.
• The processes are allocated to the components in which they execute.• Components are allocated to nodes.• A component instance executes on at least one node instance.• There are a number of aspects to consider when allocating components to
nodes.– Resource Usage of the hardware– Geographical location– Access to devices– Security– Performance– Extensibility and portability
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Deployment View
Use-CaseView
ConcurrencyView
LogicalView
DeploymentView
ComponentView
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
UML notations
Package: Subsystem, Framework
Interface
realization (simple form)
realization (expanded form)
G.Booch, J.Rumbaugh, I. Jacobson , ”The Unified Modeling Language User Guide”, Addison Wesley, 1999.
Interface
Class A Class B
Storable
Runnable
<<interface>>Runnable{abstract}
run(){ abstract}
<<interface>>Storeble
{abstract}
load(){ abstract}save(){ abstract}
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Java Implementation
interface Storable{ public void save(); public void load();};
public class Person implements Storable{ public void save(); { /* Implementation of save operation for Person */ } public void save(); { /* Implementation of load operation for Person */ }};H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Package
A pakage is a grouping mechnism, whereby all kinds of model elements can be linked
Subsystem A
Subsystem B
Subsystem D
Subsystem C
Subsystem E
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
UML notation
NodeA physical element that exists at run time and that represents a computational resource, generally having at least some memory and, often times, processing capability
ATMData
Server
G.Booch, J.Rumbaugh, I. Jacobson , ”The Unified Modeling Language User Guide”, Addison Wesley, 1999.
Node
Bill’s Machine:Dell
Pentium 466MMX
node type an instance
DellPentium 466
MMX
<<Printer>>HP LaserJet
5MP
<<CarController>>SAAB 9-5Navigator
<<Router>>Cisco Router
X2000
Device nodes and possible stereotype
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Communication Association between nodes
ClientB:Compaq Pro PC
ClientA:Compaq Pro PC
ApplicationServer:
Silicon GraphicsO2
DatabaseServer:VAX
“TCP/IP”
“TCP/IP”
<<DecNet>>
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Component Allocation
<<library>>Transaction
ClientLibrary
UNIXTransaction
ServerProgram
SiliconGraphics
O2
<<support>>
Bill’s Machine: Dell Pentium MMX PC
Executable component instances may be contained within node instance symbols, showing that they reside and execute on the node instance
A node type supporting a run-time component type, and a run-time component instance executing in a node instance
ClientProgram
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Use the services of another component
Allocation of Object
Microwave Oven System: Microwave Oven Controller
A passive object ( of ThermometerController ) within an active process object ( of active class SuperVisor ) that lives within a component instance ( of type guard.exe ), which is allocated to the node Microwave Oven System ( of type Microwave Oven Controller ).
guard.exe
<<process>> SuperVisor
ThermometerController
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Object AllocationObjects are allocated to nodes. The transobj object that originally exists in the Main Server node can be distributed to the Dell PC node shown with the stereotype <<becomes>>
Main Server: Quad Pentium PCBill’s Machine:
Dell Pentium MMX PC Transaction Server Program
transobj dlbobj callobj
t1:updatethread
Client Program
transobj
<<become>>
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Complex Modeling
Client PC
NetDrv
ApplClient
Window95
Admin PC
AdminPgm
BackupStation
Server
1backupMedium1
1..* 1..2
connected To
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Component View
Use-CaseView
ConcurrencyView
LogicalView
DeploymentView
ComponentView
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
UML notation
ComponentA component is a physical and replaceable part of a system that conforms to and provides the realization of a set of Interfaces. Graphically, a component is rendered as a rectangle with tabs.
<<executable>>
client.exe
G.Booch, J.Rumbaugh, I. Jacobson , ”The Unified Modeling Language User Guide”, Addison Wesley, 1999.
An example of a component diagram
WindowHandler
(whnd.obj)
MainClass
(main.cpp)
MainClass
(main.obj)
Graphiclib
(graphic.dll)
CommHandler
(comhnd.obj) ClientProgram
(client.exe)
WindowHandler
(whnd.cpp)
CommHandler
(comhnd.cpp)
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Three kinds of components
• Source component
• Binary component
• Executable component
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Interfaces and Dependencies
Runnableupdatethread.java
display.java
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Compile-time Component
<<file>>animlogo.java
<<file>>animator.java
<<document>>animlogo.doc
<<document>>animator.doc
<<file>> a file containing source code
<<page>> a Web page
<<document>> a document
<<page>>home.html
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Run-time Components
<<library>>graphics.dII
<<library>>dbhandler.dII
<<library>>commhandler.dII
<<application>>umlviewer.exe
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.
Use of UML• Information system
– Handle large amounts of data with complex relationships, which are stored in relational or object databases
• Technical system– Handle control technical equipment such as telecommunications, military systems,
or industrial processes. They must handle the special interfaces of the equipment and have less standard software than Information system. The are often real-time system.
• Embedded real-time systems– Execute on simple hardware embedded in some other equipment such as a mobile
phone, car, household appliance, etc.• Distributed systems
– Distributed on a number of machines where data Is transferred easily from one machine to another. They require synchronized communication mechanisms to ensure data integrity and are often built upon object mechanisms such as CORBA, COM/DCOM, or Java Beans/RMI
• System software– Define the technical infrastructure that other software uses. Operating system.
Databases.• Business system
– Describe the goals, the resources (human, computers), the rules (laws, business strategies, policies), and the actual work in the business
H.E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.