Unified Modelling Language Introduction

advertisement
Unified Modelling Language
by
Kristian Sandahl
Introduction
• A requirements specification or design
description is a road map to the coding
• Models supplement natural language
• Models support both elicitation and design
• Creating a model forces you to take
necessary decisions
• UML is becoming the standard notation
Use-case modelling
A use-case is:
“… a particular form or pattern or exemplar of
usage, a scenario that begins with some user of
the system initiating some transaction of
sequence of interrelated events.”
Jacobson, m fl 1992: Object-oriented software
engineering. Addison-Wesley
Use-case diagram
Buy a cup of coffee
CoffeeDrinker
Actor: a user of
the system in a
particular role.
Can be human
or system.
Detail of use-case
A CoffeeDrinker approaches the machine
with his cup and a coin of SEK 5. He
places the cup on the shelf just under the
pipe. He then inserts the coin, and press
the button for coffee to get coffee
according to default settings. Optionally
he might use other buttons to adjust the
strength and decide to add sugar and/or
whitener. The machine processes the
coffee and bell when it is ready. The
CoffeeDrinker takes his cup from the shelf.
Use-case diagram for the
machine
CoffeeMachine
Buy a cup of
coffe
CoffeDrinker
Clean the
Machine
Get coin in
return
Add substances
System boundary
Service
Collect coins
Pour hot water
Brew a can of
coffee
TeaDrinker
Porter
Relations between use-cases
Clean the
machine
<<include>>
Open machine
Service
Stereotype: extended
classification of meaning
Please,
Please,keep
keepas
as
simple
simpleas
aspossible.
possible.
Collect coins
<<include>>
”Reuse”
<<extend>>
Add change
”Separating scenarious”
(often conditional)
Identifying classes: noun
analysis
A CoffeeDrinker approaches the machine
with his cup and a coin of SEK 5. He
places the cup on the shelf just under the
pipe. He then inserts the coin, and press
the button for coffee to get coffee
according to default settings. Optionally
he might use other buttons to adjust the
strength and decide to add sugar and/or
whitener. The machine processes the
coffee and bell when it is ready. The
CoffeeDrinker takes his cup from the shelf.
•machine – real noun handled by
the system
•cup – unit for beverage
•coin – detail of user and machine
•shelf – detail of machine
•pipe – detail of machine
•button– handled by the system
•sugar – detail of coffee
•whitener – detail of coffee
•cup of coffee – handled by the
system
•indicator – not discovered
The single class model
CoffeCustomer
name
name: String
attribute
numberOfCoins() : Integer
buy(c:CupOfCoffee)
operations
Associations between classes
association
CoffeCustomer
0..*
buys
multiplicity
0..*
CupOfCoffee
A multiplicity can be:
•an exact number
•a range of numbers
•unspecified number denoted by *
Extended class model
CoffeCustomer
0..*
buys
0..*
CupOfCoffee
0 ..*
buy
Porter
0..*
0..*buys
s
0..*
CanOfCoffee
Revised class model
CoffeCustomer
0..*
buys
0..*
CupOfCoffee
Generalisation
association
Porter
0..*
buys
0..*
CanOfCoffee
Class model with navigability
CoffeCustomer
buys
0..*
0..*
CupOfCoffee
Generalisation
association
Porter
0..*
buys
0..*
CanOfCoffee
Class model with aggregation
Machine
1
1
1
1
1
Interface
1
CoinHandler
Brewer
More relations between classes
1..*
10..*
Topic
1
1..*
Encylopedia
Board
row:{1,2,..8}
column:{1,2,..8}
1
1
is a copy of
Copy
1..*
1..*
{xor}
is a copy of
0..*
0..*
Link
aggregation
Volume
composition
Square
qualified association
Book
constraint
Journal
The coffee machine class model
Interface
CoinHandler
Brewer
1 1
1
1
buys
CoffeeCustomer 0..* 0..*
CupOfCoffee
1
makes
0..*
1
k
ma
Porter
byus
0..1 0..*
CanOfCoffee
*
0..
1
machine
es
1
Even
Evensmall
smallmodels
modelstake
take
space.
space.You
Youneed
needgood
good
drawing
drawingtools
toolsand
andlagre
lagre
sheet.
sheet.
Classes and objects
Classes:
CoffeCustomer
0..*
buys
0..*
CupOfCoffee
Objects:
Kristian:
CoffeCustomer
buys
c1: CupOfCoffee
buys
c1: CupOfCoffee
Reasoning about an arbitrary
object
Like this:
aCoffeCustomer:
CoffeeCustomer
buys
theCupOfCoffee:
CupOfCoffee
buys
: CupOfCoffee
...or simply like this:
: CoffeCustomer
Sequence diagram
: Interface
Message
: CoffeeCustomer
insertCoin
machineReady
pressButton(b1)
time
pourCoffe
Life time of object
Sequence diagram with several
objects
: Interface
: CoinHandler
: Brewer
: CoffeeCustomer
insertCoin
A
{C-A < 5s}
transport
coinAccepted
litIndicators
pressButton(b1)
C
pourCoffee
warmUp
makeOrder(o1)
pourCoffee
State diagram
For class CoinHandler:
message this object
checking
falseCoin()/returnCoin(self)
insertCoin()/checkCoin(self)
state
start marker
event, causing
transition
action, reaction
to the event
idle
Download