Title: Modeling Behavior with UML
1Modeling Behavior with UML
2Overview
- Sequence diagrams
- Activity diagrams
- Summary
3UML Sequence Diagrams
- In requirements analysis
- To refine use case descriptions
- to find additional objects (participating
objects) - In system design
- to refine subsystem interfaces
- Columns classes
- Arrows messages
- Narrow rectangles activations
- Dashed lines lifelines
selectZone()
insertCoins()
pickupChange()
pickUpTicket()
4UML Sequence Diagrams Nested Messages
ZoneButton
to be continued...
- The source of an arrow indicates the activation
which sent the message - An activation is as long as all nested activations
5Figure 2-29. Example of a sequence diagram
setting the time on 2Bwatch.
6Figure 2-30. Examples of conditions and iterators
in sequence diagrams.
7Sequence Diagram Observations
- UML sequence diagram represent behavior in terms
of interactions. - They complement class diagrams, which represent
structure. - Useful for finding participating objects.
- Time-consuming to build but worth the investment
where interactions are complex.
8Figure 2-31. A UML statechart diagram for the
Incident class.
Active
Inactive
Closed
Archived
incidentHandled
incidentDocumented
incidentArchived
9Figure 2-32. Statechart diagram for 2Bwatch set
time function.
pressButtonsLAndR
after 2 min.
pressButtonsLAndR/beep
after 20 years
after 20 years
10Figure 2-33. Internal transitions associated with
the SetTime state (UML statechart diagram).
11Figure 2-34. Refined statechart associated with
the SetTime state (UML statechart diagram).
12Activity Diagrams
- An activity diagram shows flow control within a
system - An activity diagram is a special case of a state
chart diagram in which states are activities
(functions)
13Activity Diagrams
- Two types of states
- Action state
- Cannot be decomposed any further
- Happens instantaneously with respect to
- level of abstraction used in the model
- Activity state
- Can be decomposed further
- Activity is modeled by another activity diagram
- (cf. DFDs?)
14Activity Diagram Modeling Decisions
15Activity Diagrams Modeling Concurrency
- Synchronization of multiple activities
- Splitting the flow of control into multiple
threads
16Activity Diagrams Swimlanes
- Actions may be grouped into swimlanes to denote
the object or subsystem that implements the
actions.
17Report
Emergency
Dispatcher
OpenIncident
FieldOfficer
AllocateResources
ArchiveIncident
ManageUsers
Librarian
SysAdmin
SearchArchive
ManageTerminals
18(No Transcript)
19(No Transcript)
20(No Transcript)
21(No Transcript)
22(No Transcript)
23Summary
- UML provides a wide variety of notations for
representing many aspects of software
development - We concentrate only on a few notations
- Functional model use case diagram
- Object model class diagram
- Dynamic model sequence diagrams, statechart and
activity diagrams - UML is not a methodology, but the textbook
describes a methodology that uses UML