UML : Unified Modeling Language. ⢠Use cases. ⢠Class Diagram. ⢠Interaction Diagrams. ⢠State Diagrams. ⢠Activity Diagrams. ⢠based on Frank Maurer lecture, ...
Use cases Class Diagram Interaction Diagrams State Diagrams Activity Diagrams
• based on Frank Maurer lecture, Univ. of Calgary (http://sern.ucalgary.ca/Courses/CPSC/333/W99/CS333.html)
• Recommended: UML distilled… (Addison Wesley) UML- State Diagrams 1
State diagrams • State diagram: Shows the behavior of one object (of one class): – how does it change its state based on the messages it receives – narrowly focused, fine-grained
• Other names – State transition diagram – Harel diagram (statecharts)
UML- State Diagrams 2
State diagrams (2) • State: condition/situation during lifetime of an object • State transition: relationship indicating a state change – atomic & non-interruptible
• Action: – atomic & non-interruptible
UML- State Diagrams 3
State notation (1) • Substates: disjoint/concurrent • Entry/exit actions – entry: an action that is performed on entry to the state – exit: an action performed on exiting the state
State name state variable(s) entry: entry action do: activity-A on: event-A: action-A exit: exit-action
• do: an ongoing activity performed while in the state (example: display window) – interruptible
• on: an action performed as a result of a specific event
• Event: significant occurrence that has a location in time and space – triggers the transition – signals, calls, passing of time, change in state
• Guard condition: • Transition only eligible to fire when guard evaluates to true • Guards of transition exiting one state are mutually exclusive
• Action: executable atomic computation UML- State Diagrams 5
State diagram notation (3) Initial state
Event(attribute)
State-B
• Start state – No event triggers allowed – branch conditions allowed – may not remain in start states
• End state – Top level end state terminates a state machine UML- State Diagrams 6
State Diagram and Use Cases • When we receive an order, we check each line item of the order to see if we have the goods in stock. If we do, we assign the goods to the order. If this assignment sends the quantity of goods in stock below the reorder level, we reorder the goods. While we are doing this, we check to see if the payment is OK. If the payment is OK and we have the goods in stock, we dispatch the order. If the payment is Ok but we do not have the goods, we leave the order waiting, if the payment is not OK, we cancel the order.
UML- State Diagrams 7
• When a supply delivery comes in, we look at the outstanding orders and decide which ones we can fill from this incoming supply. We then assign each of these to its appropriate orders. Doing this may release those orders for dispatching. We put the remaining goods in stock.
UML- State Diagrams 8
State transitions for an order get next item[ not all items checked ]
/ get first item
Item received[ some items not in stock ]
[ All items checked && some items not in stock ]
Checking
Waiting
do: check item
[ All items checked && all items available ]
Item received[ all items available ]
Dispatching
Delivered
do: initiate delivery
UML- State Diagrams 9
Delivered
Problem: Cancel the order • Want to be able to cancel an order at any time • Solutions – Transitions from every state to state “cancelled” – Superstate and single transition
UML- State Diagrams 10
Transitions to “cancelled” get next item[ not all items checked ]
/ get first item
Item received[ some items not in stock ]
[ All items checked && some items not in stock ]
Checking
Waiting
do: check item
[ All items checked && all items available ]
Item received[ all items available ] cancelled cancelled
Dispatching do: initiate delivery
cancelled Cancelled
Delivered
Delivered
UML- State Diagrams 11
State diagram notation (4) Superstate
Event A
State-A
Event B
UML- State Diagrams 12
State-B
Event C
Superstate Active
get next item[ not all items checked ]
/ get first item
Checking do: check item
Item received[ some items not in stock ]
[ All items checked && some items not in stock ]
Waiting cancelled
Cancelled
Item received[ all items available ]
[ All items checked && all items available ]
Delivered Dispatching do: initiate delivery
Delivered
UML- State Diagrams 13
Some remarks • Only one initial state may occur (directly) within a composite state • End state represents completion of a composite • End state triggers transition with composite as source
UML- State Diagrams 14
Concurrent state diagram • Unrelated components of objects combinatorial number of states • Example: Car states 4 car states: started_open started_closed stopped_open stopped_closed
• What happens when we add one component? – seat belt (fastened, open) 8 car states: started_open_open started_closed_open stopped_open_open stopped_closed_open
2 parallel processes: - authorization - order handling
[ payment not ok ]
[ payment ok ] Rejected
Authorized
Delivered
UML- State Diagrams 16
Concurrent state diagram for the class Order Cancelled
cel can
Waiting
Checking
Dispatching
Delivered
Authorizing
Authorized
[
[Payment not OK]
Rejected
UML- State Diagrams 17
Rules of thumb • Not every class needs a state diagram • Often: State diagram not very complex • State diagrams are often used for UI and control objects • Not to many concurrent sets of behavior occurring in a single object (in that case: split into separate objects)
UML- State Diagrams 18
TBu i l d e r 3 0 /1 1 /2 0 0 1 Si tu a ti o n d 'u n ter ra i n
- nom des états -gestion du nombre des maisons -… Acheter /Achat_propriété( ) libre a ch e té Vendre /Vente_propriété( ) Rés ilier hypothèque /Résilier_propriété( )
hypothèquer /Hypothéquer_propriété( )
Construire /Achat_batim ent( )
h yp o th é q u é Destruire /Vente_batim ent( )
b a ti m e n t
Destruire_hotel /Vente_batiment( )
struire_mais on(Nbre2]
Construire hôtel [si il y a 4 maisons] Te rra i n a ve c m a i s o n (s )
Oct 4, 2004 - These diagrams contain all possible siteswaps for .... This document was produced using the LATEX typesetting program with the XY-pic ...
jo Aiacanthus Pasco II (127). /o Bathophilus...proximas (23). 25 Stemonosud is nacrurus (6a). 25 Sudis atrox C/C). 23 Occa is satra ... l. (20). Field Data Sheet: ...
Figure 2.1 presents a monitoring system for simultaneous supervision of. 16 measuring ... FIGURE 2.1 Monitoring system. ..... by asynchrony or direct current electric motors. ..... tools have been chosen: (a) the moment of control, divided into offli
Page 1 ... development of an âextended PLMâ (Product Life Management) tool to support the organisational structure, document ... in a collective action (working in practice towards a consensus end). In a given ... collaboration and communication
Vocabulary and diagrams. Vocabulary: continuous â bar graph - class - data â discrete â frequency â frequency table â pie chart â population - qualitative ...
edge compilation perspective, i.e., to derive more succinct compiled representations while preserving queries and transformations of in- terest. In order to reach ...