UML 2.0 crash course Birger Møller-Pedersen, Øystein Haugen

advertisement
OMS seminar 2004
UML 2.0
crash course
Birger Møller-Pedersen,
Øystein Haugen
21-Sep-04
Haugen / Møller-Pedersen
1
UML standardization within OMG – for Ericsson
better tools
developers
world-wide
Ericsson
UML standardization
team
issuing
requirements
in cooperation
with alllies
contributing
in cooperation
with
tool vendors
21-Sep-04
OMS seminar 2004
improved
Requirements from
Haugen / Møller-Pedersen
2
1
Why UML2.0?
ƒ for Ericsson, Motorola, Alcatel, Nokia (telecom, realtime)
– SDL/MSC
– UML/ROOM (as by RoseRT)
only one vendor
only one vendor
ƒ for others
– Scalability, modeling of large, complex systems
– Improvement of existing concepts: activities, components,
– Completeness: action semantics, formal/precise definition
ƒ in general
OMS seminar 2004
– UML2.0 combining features from these
– Experiences with UML1.x required an improvement
– Model Based Development requires a good modeling language
21-Sep-04
Haugen / Møller-Pedersen
3
Very Short History
ƒ December 1999
RFI (Request For Information)
– 29 Responses to the RFI
– Ericsson made a joint response with Motorola and Alcatel (and
Nokia)
September 2000
October 2001
August 2002
June 2003
Now
ƒ April 2004
21-Sep-04
RFP (Request For Proposal)
Initial submission
Revised submission
Recommended for adoption
Finalization Task Force
OMS seminar 2004
ƒ
ƒ
ƒ
ƒ
ƒ
Final spec
Haugen / Møller-Pedersen
4
2
!
??
ROOM
SDL
Snapshot
from one of
the meetings
Haugen / Møller-Pedersen
21-Sep-04
Haugen / Møller-Pedersen
5
OMS seminar 2004
21-Sep-04
OMS seminar 2004
UML
6
3
OMS seminar 2004
21-Sep-04
Haugen / Møller-Pedersen
7
Example - ATM
ƒ Domain statement
21-Sep-04
Haugen / Møller-Pedersen
OMS seminar 2004
– An Automatic Teller Machine (ATM) is a system with mechanical as
well as electronic parts. Its purpose is to provide a bank user with
cash provided that the user can authenticate herself and she has
adequate funds in her bank account.
– She authenticates herself by presenting a card to the ATM
cardreader, and a personal identification number (PIN) through the
ATM keyboard.
– The ATM is connected electronically and possibly through some
kind of network to the bank such that the account status may be
checked online.
– The ATM is refilled with cash notes regularly or when the number of
specific notes is below some limit.
– The ATM may also provide foreign currency to the customer
8
4
Domain Model I
User
ATM
*
*
*
1
Bank
1
*
*
Card
1
1
Account
OMS seminar 2004
1
myAccounts
21-Sep-04
Haugen / Møller-Pedersen
9
Domain Model II
ATM
21-Sep-04
Keyboard
Screen
Haugen / Møller-Pedersen
CashDispenser
OMS seminar 2004
CardReader
10
5
Use Case Model
ATM
CashRepository
Authentication
User
<<uses>>
Bank
Currency
21-Sep-04
Haugen / Møller-Pedersen
OMS seminar 2004
<<uses>>
Withdrawal
11
Context model with UML1.x class diagrams
ƒ with plain composition and no encapsulation
ƒ with only provided interfaces on classes
ATM-Bank
User-ATM
ATM
User
21-Sep-04
Keyboard
Screen
Haugen / Møller-Pedersen
CashDispenser
OMS seminar 2004
CardReader
Bank
12
6
Composite class (incomplete)
part
ƒ with parts, ports and connectors
ATM
User-Reader
port
ATM-bank
User-Screen
:Screen
User-Keyboard
:Keyboard
connector
:CashDispenser
OMS seminar 2004
:CardReader
User-Cash
21-Sep-04
Haugen / Møller-Pedersen
13
Context Model in UML2.0 - I
ƒ composite structure as part of a Collaboration
BankContext
ATM-bank
:User
:Bank
:ATM
User-Screen
User-Keyboard
User-Cash
21-Sep-04
Haugen / Møller-Pedersen
OMS seminar 2004
User-Reader
14
7
Context Model in UML2.0 - II
ƒ Including multiplicities on parts
multiplicity
BankContext
:User
[1..10.000]
ATM-bank
:ATM [1..100]
:Bank
User-Screen
User-Keyboard
User-Cash
21-Sep-04
Haugen / Møller-Pedersen
OMS seminar 2004
User-Reader
15
Sequence Diagrams (Interactions)
ƒ Sequence Diagrams are
simple
powerful
readable
used to describe interaction sequences
ƒ History
–
–
–
–
Has been used for a number of years informally
Standardized 1992 in Z.120 (Message Sequence Charts - MSC)
Last major revision of MSC is from 1999 (called MSC-2000)
Formal semantics of MSC-96 is given in Z.120 Annex B
OMS seminar 2004
–
–
–
–
– Included in UML from 1999, but in a rather simple variant
21-Sep-04
Haugen / Møller-Pedersen
16
8
Purpose
ƒ Emphasizes the interaction between objects indicating
that the interplay is the most important aspect
– Often only a small portion of the total variety of behavior is
described improve the individual understanding of an interaction
problem
OMS seminar 2004
ƒ Sequence Diagrams are used to ...
–
–
–
–
–
document protocol situations,
illustrate behavior situations,
verify interaction properties relative to a specification,
describe test cases,
document simulation traces.
21-Sep-04
Haugen / Møller-Pedersen
17
(Simple) Sequence Diagram
ƒ Messages have one send event, and one receive event.
– The send event must occur before the receive event.
– The send event is the result of an Action
ƒ Events are strictly ordered along a lifeline from top to bottom
sd EnterPIN
:User
The name of the interaction
:ATM
:Bank
msg(”Give PIN”)
Digit
Receive Event
Digit
Continuation
Digit
Digit
OMS seminar 2004
The frame
(UML 2)
Code(cid, pin)
Send Event
OK
Message name
21-Sep-04
PIN OK
Haugen / Møller-Pedersen
18
9
Combined fragment example
sd EnterPIN
:User
:ATM
:Bank
msg(”Give PIN”)
combined fragment
frame
Digit
Digit
operator
Digit
Code(cid, pin)
operand
separator
alt
NOK
PIN NOK
OMS seminar 2004
Digit
OK
PIN OK
21-Sep-04
Haugen / Møller-Pedersen
19
Combined fragments of Interaction
ƒ We want to express
– choices: alternative, option, break
– parallel merge
– loops
– negation
– critical region
– assertion
ƒ Other suggested operators that will not come in UML 2.0
– interrupt
– disrupt
21-Sep-04
Haugen / Møller-Pedersen
OMS seminar 2004
ƒ We may also want to add other operators
20
10
References (Interaction Use / Occurrence)
sd Authenticate
reference
:User
:ATM
:Bank
Idle
Continuation
ref
EnterPIN
loop(0,3)
PIN NOK
msg("Try again!")
ref
OMS seminar 2004
Cardid(cid)
EnterPIN
21-Sep-04
Haugen / Møller-Pedersen
21
Nested combined fragments
reference
sd Withdrawal
:User
combined fragment
ref
:ATM
:Bank
Authenticate
alt
Continuation
PIN OK
Withdrawal
msg("Give amount!")
amount(v)
alt
checkaccount(v)
money(v)
ok
receipt(v)
nok
msg(”Amount too large”)
PIN NOK
OMS seminar 2004
nested fragment
msg(”Illegal entry”)
card
card taken
21-Sep-04
Haugen / Møller-Pedersen
22
11
Interaction Overview Diagram
sd Withdrawal
reference
ref
combined fragment
Authenticate
PIN NOK
PIN OK
sd
:User
:ATM
sd
:Bank
Withdrawal
:User
msg("Give amount!")
Continuation
:ATM
msg(”Illegal entry”)
checkaccount(v)
sd
sd
:User
money(v)
:ATM
:Bank
:User
:ATM
:Bank
nok
ok
msg(”Amount too large”)
receipt(v)
Inline diagram
OMS seminar 2004
nested fragment
amount(v)
sd
:User
:ATM
card
card taken
21-Sep-04
Haugen / Møller-Pedersen
23
EnterPIN state machine
<<statemachine>>
EnterPIN
sm EnterPIN
send(msg(”Give PIN”)); n=1; PIN=0
n:integer
PIN: integer
enterDigit
[n<4]digit/
n++;
PIN= PIN+digit*10(3-n)
nok
nok
waitOK
ok
ok
OMS seminar 2004
[n=4]digit/PIN=...
send(Code(cid,PIN))
definition of exit point
21-Sep-04
Haugen / Møller-Pedersen
24
12
use of exit point
Statemachine for the ATM
sm ATM
Idle
/authN=0
CardId(cid)
/authN=0
:EnterPIN
:Service
ok
:Withdrawal
:Status
cancelled
ok
[authN==3]/
authN=0
send(msg(
”illegal entry”));
OMS seminar 2004
status
Withdrawal
nok
[authN<3]/
authN++;
send(msg(”Try again”))
CardOut
entry: send(card)
cardTaken
21-Sep-04
Haugen / Møller-Pedersen
25
Attributes of the ATM
ƒ Statemachine is a Classifier
(that is class-like):
– Attributes
– Operations (local actions)
authN:integer
cid: integer
sa: Amount
aa: Amount
ƒ
ƒ
ƒ
ƒ
authN
cid
sa
aa
number of tries
card id
selected amount
available amount
OMS seminar 2004
<<statemachine>>
ATM
sendMoney(a:Amount)
21-Sep-04
Haugen / Møller-Pedersen
26
13
State machine Withdrawal
sm Withdrawal
cancelled
cancelled
:GetAmount
use of
entry point
nok/
send(msg(”Amount too large”))
VerifyTransaction
ok/
sendMoney(sa);
send(Receit(sa));
OMS seminar 2004
again
send(CheckAccount(sa))
ok
21-Sep-04
Haugen / Møller-Pedersen
27
Simple GetAmount
sm GetAmount
Send(msg(”select amount”))
cancel
Send(msg(”select another amount”))
amount(sa);
OMS seminar 2004
cancelled
:SelectAmount
again
definition of
entry point
21-Sep-04
Haugen / Møller-Pedersen
28
14
Extended GetAmount
<<statemachine>>
ATM
<<statemachine>>
GetAmount
inherited state
sm GetAmount {extended}
<<statemachine>>
GetAmount {extended}
:SelectAmount
otherAmount/
send(msg(”enter amount”))
:enterAmount
cancelled
cancel
OMS seminar 2004
<<statemachine>>
FlexibleATM
ok
redefined transition
Send(msg(”enter another amount”))
again
21-Sep-04
Haugen / Møller-Pedersen
29
Another similar service: Currency
sd Currency
:User
:ATM
ref
:Bank
Authenticate
alt
PIN OK
Currency
OMS seminar 2004
msg("Give currency!")
EUR
msg("Give amount!")
checkaccount(v(e))
amount(e)
alt
[enough on account]
EUR(e)
ok
receipt(v)
msg(”Amount too large”)
[inadequate funds]
nok
PIN NOK
msg(”Illegal entry”)
card
card taken
21-Sep-04
Haugen / Møller-Pedersen
30
15
Interactions are generalizable and redefinable
sd GenWithdrawal
:User
:ATM
ref
GenWithdrawal
actual
gate
:Bank
sd getAmount
sd giveMoney
Authentication
alt
PIN OK
Withdrawal
Currency
redefined getAmount
redefined giveMoney
getAmount
:User
redefined getAmount
redefined giveMoney
:ATM
checkaccount(v(e))
Currency
alt
[enough on account]
ref
ok
giveMoney
msg("Give currency!")
EUR
receipt(v)
msg(”Amount too large”)
nok
msg("Give amount!")
[inadequate funds]
formal
gate
amount(e)
PIN NOK
OMS seminar 2004
sd getAmount
ref
sd giveMoney
msg(”Illegal entry”)
:User
:ATM
card
EUR(e)
card taken
21-Sep-04
Haugen / Møller-Pedersen
ok
31
ATM revisited - generalised
sm ATM
Idle
/authN=0
CardId(cid)
/authN=0
:EnterPIN
:Service
ok
:Status
[authN==3]/
authN=0
send(msg(
”illegal entry”));
OMS seminar 2004
status
nok
[authN<3]/
authN++;
send(msg(”Try again”))
CardOut
entry: send(card)
cardTaken
21-Sep-04
Haugen / Møller-Pedersen
32
16
Extended state machines
sm WithdrawalATM
sm CurrencyATM
:Service
{extended}
:Service
{extended}
Withdrawal
Currency
ok
:Currency
cancelled
ok
CardOut
cancelled
OMS seminar 2004
:Withdrawal
CardOut
21-Sep-04
Haugen / Møller-Pedersen
33
Decomposing a Lifeline wrt an Interaction
sd Authenticate
:User
:ATM
ref ATM_Authenticate
:Bank
Idle
ref
EnterPIN
loop(0,3)
PIN NOK
msg("Try again!")
ref
EnterPIN
we want to look
into this lifeline
21-Sep-04
Haugen / Møller-Pedersen
this is the name
of the diagram
where we find the
decomposition
OMS seminar 2004
Cardid(cid)
34
17
Decomposition
sdAuthenticate
sd ATM_Authenticate
:ATM
ref ATM_Authenticate
:User
:Bank
:CardReader
:CashDispenser
Idle
ref
EnterPIN
:Keyboard
:Controller
ATM_Idle
Cardid(cid)
Cardid(cid)
Code(cid, pin)
ref
ATM_EnterPIN
OK, NOK
loop(0,3)
loop(0,3)
PINNOK
ATM_PIN NOK
msg("Tryagain!")
msg("Try again!")
ref
EnterPIN
msg("Try again!")
Code(cid, pin)
ref
OMS seminar 2004
Cardid(cid)
:Screen
ATM_EnterPIN
NOK
notice the
correspondance!
notice the
correspondance!
21-Sep-04
Haugen / Møller-Pedersen
35
Composite (design) class
ATM
User-Reader
:Controller
:Screen
User-Keyboard
:Keyboard
:CashDispenser
ATM-bank
OMS seminar 2004
User-Screen
:CardReader
User-Cash
21-Sep-04
Haugen / Møller-Pedersen
36
18
Structured Classes are like other Classes
ATM
User-Reader
:CardReader
:Controller
User-Screen
ATM-bank
:Screen
:Keyboard
:CashDispenser
User-Cash
ƒ Structured Classes may have
OMS seminar 2004
User-Keyboard
– attributes & operations, interfaces, …
ƒ Internal structure is inherited, inherited parts may be redefined by
extension
21-Sep-04
Haugen / Møller-Pedersen
37
What about Components?
ƒ Have all the properties of structured classes
ƒ In addition:
ƒ Artifacts, nodes, …
ƒ Still to be stereotyped for e.g. .NET and EJB components
21-Sep-04
Haugen / Møller-Pedersen
OMS seminar 2004
– A kind of ‘package’, i.e. it may have model elements that you
would not have for classes
– Realization by a number of classes
– Deployment
38
19
Finally
ƒ Tools
IBM (Rational)
Telelogic
I-Logix
Softteam
general
real-time, telecom, but moving towards general
real-time, telecom, control systems
general, with emphasis on profiling
ƒ Books
–
–
–
–
21-Sep-04
Selic et al. (eds) UML for Real (Chapter 3)
Chonoles and Schardt: UML2.0 for Dummies
Fowler UML Distilled (Third Edition)
Coming soon: Rumbaugh: UML Reference Manual
Haugen / Møller-Pedersen
OMS seminar 2004
–
–
–
–
39
20
Download