Documente Academic
Documente Profesional
Documente Cultură
Luca Vigan
Dipartimento di Informatica Universit di Verona
System Models IV
1 / 75
Table of contents
1 2
Introduction: dynamic models Sequence diagrams From Use Cases to sequence diagrams Recommended layout of sequence diagrams State-dependent behavior Statecharts Activity diagrams System models Conclusions
4 5
System Models IV
2 / 75
To explain why the context of a system should be modeled as part of the requirements engineering process. To describe behavioral modeling, data modeling, and object modeling. To introduce some of the notations used in the Unied Modeling Language (UML). Today we will focus on dynamic modeling.
System Models IV
3 / 75
Outline
1 2
Introduction: dynamic models Sequence diagrams From Use Cases to sequence diagrams Recommended layout of sequence diagrams State-dependent behavior Statecharts Activity diagrams System models Conclusions
4 5
System Models IV
4 / 75
The context
Requirements analysis and definition System and software design Implementation and unit testing Integration and system testing Operation and maintenance
Goal: Specify the requirements as far as possible, but as abstractly as possible. Modeling languages and methods are used here!
Luca Vigan (Universit di Verona) System Models IV Ingegneria del SW, 06.04.11 5 / 75
The context
Requirements analysis and definition System and software design Implementation and unit testing Integration and system testing Operation and maintenance
System Models IV
6 / 75
dynamic
Main Concepts class, association, generalization, dependency, realization, interface use case, actor, association, extend, include, use case generalization component, interface, dependency, realization node, component, dependency, location state, event, transition, action state, activity, completion transition, fork, join interaction, object, message, activation collaboration, interaction, collaboration role, message package, subsystem, model constraint, stereotype, tagged values
Ingegneria del SW, 06.04.11 7 / 75
System Models IV
8 / 75
Dynamic modeling
Dynamic modeling: within and between objects. Introduction to different kinds of models. Sequence diagrams: information ow (messages) between objects. Statecharts: state oriented; both within and between. Activity diagrams: state oriented; emphasizes coordination between objects. Applications.
System Models IV
9 / 75
Sequence diagrams
Outline
1 2
Introduction: dynamic models Sequence diagrams From Use Cases to sequence diagrams Recommended layout of sequence diagrams State-dependent behavior Statecharts Activity diagrams System models Conclusions
4 5
System Models IV
10 / 75
Sequence diagrams
Sequence diagrams
System Models IV
11 / 75
Sequence diagrams
Syntax:
Name of objects (instead of classes!). Lifeline of the object with activation rectangle. Arrows indicate message passing; further annotation possible.
Restrictions:
Branching points possible, but difcult; one scenario at a time is standard. No support for hierarchy. No liveness; one only species what can happen, not what must happen.
Luca Vigan (Universit di Verona) System Models IV Ingegneria del SW, 06.04.11 12 / 75
Sequence diagrams
System Models IV
13 / 75
Sequence diagrams
Nested messages
System Models IV
14 / 75
Sequence diagrams
System Models IV
15 / 75
Sequence diagrams
{C - A < 5 sec}
Other extensions supported like annotation for multi-threaded applications (e.g. thread numbering, special arrow for asynchronous message passing, etc.).
Luca Vigan (Universit di Verona) System Models IV Ingegneria del SW, 06.04.11 16 / 75
Sequence diagrams
Sequence diagrams are derived from ows of events of Use Cases. An event always has a sender and a receiver.
Find the objects for each event.
System Models IV
18 / 75
Sequence diagrams
System Steps
2. Bankomat displays options 4. Bankomat queries amount 5. Client enters amount 6. Bankomat returns bank card listed as extension point 7. Bankomat outputs specied amount
System Models IV
19 / 75
Sequence diagrams
System Models IV
20 / 75
Sequence diagrams
System Models IV
21 / 75
Sequence diagrams
System Models IV
23 / 75
Sequence diagrams
Creation of objects: Control objects are created at the initiation of a Use Case. Control objects are often created by boundary objects. Access of objects: Entity objects are accessed by control and boundary objects. Entity objects should never access boundary or control objects.
Easier to share entity objects across Use Cases. Makes entity objects resilient against technology-induced changes in boundary objects.
System Models IV
24 / 75
Sequence diagrams
Fork structure
System Models IV
25 / 75
Sequence diagrams
Stair structure
System Models IV
26 / 75
Sequence diagrams
System Models IV
27 / 75
Sequence diagrams
Sequence diagrams represent behavior in terms of interactions. Complement the class diagrams (which represent structure). Useful:
To nd missing objects. To detect and supply operations for the object model.
System Models IV
28 / 75
State-dependent behavior
Outline
1 2
Introduction: dynamic models Sequence diagrams From Use Cases to sequence diagrams Recommended layout of sequence diagrams State-dependent behavior Statecharts Activity diagrams System models Conclusions
4 5
System Models IV
29 / 75
State-dependent behavior
State-dependent behavior
Examples:
Withdrawal: has state-dependent behavior. Account: has state-dependent behavior (e.g. locked). Display: does not have state-dependent behavior.
System Models IV
30 / 75
State-dependent behavior
Event: something that happens at a point in time. Typical event: receipt of a message. Other events: change event for a condition, time event. Action: operation in response to an event. Example: object performs a computation upon receipt of a message. Activity: operation performed as long as object is in some state. Example: object performs a computation without external trigger.
System Models IV
31 / 75
State-dependent behavior
State
State: an abstraction of the attribute values of an object. A state is an equivalence class of all those attribute values and links that do not need to be distinguished as far as the control structure of the class or the system is concerned. Example: state of a book:
A book is either borrowable or not. Omissions: bibliographic data. All borrowable books are in the same equivalence class, independent of their author, title, etc.
System Models IV
32 / 75
State-dependent behavior
Example: When the left mouse button is pressed, an option menu appears. Such models correspond to transition systems , Q , . Also called state machines or (an extended variant of) automata.
System Models IV
33 / 75
State-dependent behavior
Machines specify system states and control ow. State system function, transition event.
Luca Vigan (Universit di Verona) System Models IV Ingegneria del SW, 06.04.11 34 / 75
State-dependent behavior
Transitions/Events: Event Description Half Power Half Power button pressed Full Power Full Power button pressed Timer Timer-knob turned . . . . . .
Luca Vigan (Universit di Verona) System Models IV Ingegneria del SW, 06.04.11 35 / 75
State-dependent behavior
Statecharts
Statecharts
Statechart extension (Harel 1987) solves this problem and supports models where time and reactivity can be modeled.
System Models IV
37 / 75
State-dependent behavior
Statecharts
A state diagram relates events and states for a class. Often called state chart or statechart diagram.
Luca Vigan (Universit di Verona) System Models IV Ingegneria del SW, 06.04.11 38 / 75
State-dependent behavior
Statecharts
Syntactic entities: states, transitions, events, stop symbol and start symbol. State depends on the attribute variable on the shelf. Interface supplies borrow and return methods. Partial specication: model species what happens in a particular state. Extension with error/exception states is possible. Note abstraction: the copy object can have other attributes (e.g., ISBN number, etc.). These play no role here.
System Models IV
39 / 75
State-dependent behavior
Statecharts
Actions
Transitions can specify actions:
on loan return()/book.returned(self) on the shelf borrow()/book.borrowed(self)
Syntax: E /A where E is an event and A an action. An action is what an object does, e.g., send a message. Here the Copy object sends a message to the Book object.
on loan exit/book.returned(self)
Entry/Exit: action possible (also in combination with transition actions). Both examples have the same meaning.
Luca Vigan (Universit di Verona) System Models IV Ingegneria del SW, 06.04.11 40 / 75
State-dependent behavior
Statecharts
aState exit/baz()
someEvent /bar()
anotherState entry/foo()
System Models IV
41 / 75
State-dependent behavior
Statecharts
System Models IV
42 / 75
State-dependent behavior
Statecharts
System Models IV
43 / 75
State-dependent behavior
Statecharts
System Models IV
44 / 75
State-dependent behavior
Statecharts
not borrowable
borrowable
A guard is a Boolean expression. UML is open (= vague) concerning precise syntax. Can be (precise, natural) language, OCL, or a programming language.
Luca Vigan (Universit di Verona) System Models IV Ingegneria del SW, 06.04.11 45 / 75
State-dependent behavior
Statecharts
E[C]/A S1
Transition occurs when:
System is in S1. Event E occurred in the last step. Condition C holds.
S2
Events immediately follow. A formal semantics (with time) is actually rather subtle!
Luca Vigan (Universit di Verona) System Models IV Ingegneria del SW, 06.04.11 46 / 75
State-dependent behavior
Statecharts
System Models IV
47 / 75
State-dependent behavior
Statecharts
System Models IV
48 / 75
State-dependent behavior
Statecharts
Hierarchy
States are tree structured:
A B D E C
System is in a ground state and in all parent states. Higher-level-transitions have priority over lower-level ones:
V E S S F E/B F U E
G/A
T G
T G
System Models IV
49 / 75
State-dependent behavior
Statecharts
Parallelism
OR-states: system in at most one state of current level. AND-states: simultaneously in all states of current level = parallelism.
I
UX H
VX
X E
U
E
E and I
E and H E
G Y
G
UY H F and I
VY
F and H F I
Z F
UZ
VZ
G and I
G and H
System Models IV
50 / 75
State-dependent behavior
Statecharts
/X:=N
S1
E/X:=1;
S2
S3
/X:=5
S4
/X:=X+1
S5
System Models IV
51 / 75
State-dependent behavior
Statecharts
Default connector
System Models IV
52 / 75
State-dependent behavior
Statecharts
S SU SV
T U
H
T V U V
System Models IV
53 / 75
State-dependent behavior
Statecharts
Switch connector
T F/B S
T E and F/A;B
E/A
U E and G/A;C
G/C
System Models IV
54 / 75
State-dependent behavior
Statecharts
Idle
Terminate climate
Sunrise/ Lighton()
Nighttime
State-dependent behavior
Statecharts
Cooling
Ok
System Models IV
56 / 75
State-dependent behavior
Statecharts
Cooling
Failure
Failure cleared
Failure H
Create log
Created
Fan running
History connector used to create log only once. Semantics subtle: interaction between Failure cleared and Post.
Luca Vigan (Universit di Verona) System Models IV Ingegneria del SW, 06.04.11 57 / 75
State-dependent behavior
Activity diagrams
Activity Diagrams
A (simple) alternative to statecharts.
Emphasizes synchronization within and between objects.
[returner]
record return
record borrowing
System Models IV
59 / 75
State-dependent behavior
Activity diagrams
Syntax/Semantics
Syntax:
Activity: a kind of state, left when the activity is nished. Transition: normally not labeled, since the event is the end of an activity. Synchronization bars: describes synchronization points. Decision diamonds: shows decisions, alternative to guards. Start and end markers: like in statecharts. Swim-lanes: shows which object carries out which activity.
System Models IV
60 / 75
State-dependent behavior
Activity diagrams
State diagrams help to identify Changes to an individual object over time. Sequence diagrams help to identify The temporal relationship of between objects. Sequence of operations as a response to one or more events.
System Models IV
61 / 75
State-dependent behavior
Activity diagrams
Construct dynamic models only for classes with signicant dynamic behavior.
Avoid analysis paralysis.
Look at the granularity of the application when deciding on actions and activities. Reduce notational clutter.
Try to put actions into superstate boxes (look for identical actions on events leading to the same state).
System Models IV
62 / 75
System models
Outline
1 2
Introduction: dynamic models Sequence diagrams From Use Cases to sequence diagrams Recommended layout of sequence diagrams State-dependent behavior Statecharts Activity diagrams System models Conclusions
4 5
System Models IV
63 / 75
System models
Glossary.
System Models IV
64 / 75
System models
System Models IV
65 / 75
System models
= functional model
Create scenarios and Use Case diagrams. Talk to client, observe, get historical records.
= object model
Create class diagrams. Identify objects, associations and their multiplicity, attributes, operations.
= dynamic model
Create sequence diagrams. Show senders, receivers, and sequence of events. Create state diagrams (for the interesting objects).
System Models IV
66 / 75
System models
Dominance of models
Object model:
The system has classes with non-trivial states and many relationships between the classes.
Dynamic model:
The model has many different types of events: input, output, exceptions, errors, etc.
Functional model:
The model performs complicated transformations (e.g. computations consisting of many steps).
System Models IV
67 / 75
System models
System Models IV
68 / 75
Conclusions
Outline
1 2
Introduction: dynamic models Sequence diagrams From Use Cases to sequence diagrams Recommended layout of sequence diagrams State-dependent behavior Statecharts Activity diagrams System models Conclusions
4 5
System Models IV
69 / 75
Conclusions
Key points
Systems have both static and dynamic aspects. Dynamics can be viewed/modeled in different ways. For example, focusing on state versus communication. Diagrams can be combined to give fuller system model.
System Models IV
70 / 75
Conclusions
Bibliography
Ian Sommerville. Software Engineering. Pearson Education Ltd. Martin Fowler. UML distilled (3rd ed.). Addison Wesley. Sinan Si Alhir. UML in a nutshell. OReilly. To draw dynamic Diagrams (and other UML diagrams):
Poseidon for UML (http://www.gentleware.com). ArgoUML (http://argouml.tigris.org/).
System Models IV
71 / 75
Conclusions
System Models IV
72 / 75
Conclusions
EventOffer Instructor
+Name: +Rank: +ResearchGroup: +AdditionalInformation: +ExpectedAttendants: participates +Title: 1..* 0..* +Type: +Requirements: 1 contains 1 contains contains 1
ClassSchedule
1
1..*
EventAssignement
1
RoomOffer
contains
1..*
DayBeginDuration
+Day: +Begin: +Duration: contains 1..* 1
PreferredDayBeginDurations
System Models IV
73 / 75
Conclusions
System Models IV
74 / 75
Conclusions
Homework
We continue with the semi-formal analysis of the requirements of our Class Scheduling System software-project.
1
System Models IV
75 / 75