Lecture 07 - System Modeling - Dynamic Modeling
Lecture 07 - System Modeling - Dynamic Modeling
Dynamic Modeling
Dynamic Modeling
• Dynamic Modeling
– Dynamic Modeling with UML
– Dynamic Modeling overview
– How do we detect Operations?
– Event
• Sequence diagrams
• State diagrams
• Using dynamic modeling for the design of user interfaces
• Dominant Models based on system features
Dynamic Modeling with UML
– Sequence Diagram:
• Describes the dynamic behavior of several objects over time
• Good for real-time specifications
UML State Chart Diagram
• Dynamic Modeling
• Sequence diagrams
– Sequence Diagram Overview
– Purpose Sequence Diagram
– Stair Diagram
– Fork Diagram
– Sequence Diagram UML Representation
– Sequence Diagram Examples
• State diagrams
• Using dynamic modeling for the design of user interfaces
• Dominant Models based on system features
Sequence Diagram
Control
Object
Stair Diagram
• Activations
– A thin rectangle on a lifeline) represents the period during
which an element is performing an operation.
– The top and the bottom of the of the rectangle are aligned
with the initiation and the completion time respectively
Sequence Diagram Notation - Messages
• Messages depict the invocation of operations are shown horizontally.
• They are drawn from the sender to the receiver.
• Ordering is indicated by vertical position
• The line type and arrowhead type indicates the type of message
being used:
• A synchronous message
– (typically an operation call) is shown as a solid line with a filled
arrowhead.
– It is a regular message call used for normal communication between
sender and receiver.
– typically represents operation call - send message and suspend
execution while waiting for response.
Sequence Diagram Notation - Messages
• An asynchronous message
– has a solid line with an open arrowhead.
– A signal is an asynchronous message that has
no reply.
– send message and proceed immediately
without waiting for return value
• Return message
– uses a dashed line with an open arrowhead..
– Return message is a kind of message that
represents the pass of information back to the
caller of a corresponded former message.
Sequence Diagram Notation - Creation and
Destruction Messages
• Create Message / Constructor message
– creates its receiver.
– The sender that already exist at the start of the
interaction are placed at the top of the
diagram. Targets that are created during the
interaction by a constructor call are
automatically placed further down the diagram.
– Create message is a kind of message that
represents the instantiation of (target) lifeline.
• Destroy Message / Destructor message
– destroys its receiver.
– Destroy message is a kind of message that
represents the request of destroying the
lifecycle of target lifeline.
– Only when a target's destruction is set to 'after
destructor' do you have to use a destructor.
Sequence Diagram Notation - Creation and
Destruction Messages
• Non instantaneous message / Duration
Message
– Messages are often considered to be
instantaneous, thus, the time it takes to arrive
at the receiver is negligible. The messages are
drawn as a horizontal arrow. To indicate that it
takes a certain while before the receiver
actually receives a message, a slanted arrow
is used.
– Duration message shows the distance
between two time instants for a message
invocation.
Sequence Diagram Notation - Event and Focus
of Control
• An Event : is any point in an interaction where something occurs.
• Focus of control: also called execution occurrence, an execution
occurrence
• It shows as tall, thin rectangle on a lifeline)
• It represents the period during which an element is performing an
operation. The top and the bottom of the rectangle are aligned with
the initiation and the completion time respectively.
Sequence Diagram Notation - Sequence
Fragments
• Sequence fragments make it easier to create and maintain accurate
sequence diagrams
• A sequence fragment is represented as a box, called a combined
fragment, which encloses a portion of the interactions within a
sequence diagram
• The fragment operator (in the top left cornet) indicates the type of
fragment
• Fragment types: ref, assert, loop, break, alt, opt, neg
Sequence Diagram Notation - Sequence
Fragments
Operator Fragment Type
Alternative multiple fragments: only the one whose condition is true will
alt
execute.
Alternate path
• If the Customer did not enter the name of an author before pressing
the Search button, the System displays an error message
Sequence Diagram for Modeling Use Case
Scenarios
Dynamic Modeling
• Dynamic Modeling
• Sequence diagrams
• State diagrams
– State Diagram Overview
– State Chart Diagram vs Sequence Diagram
– State Diagram Components
– State Diagram Examples
• Using dynamic modeling for the design of user interfaces
• Dominant Models based on system features
State Diagrams
• As an example, the following state • The door can be in one of three states:
machine diagram shows the states "Opened", "Closed" or "Locked".
that a door goes through during its • It can respond to the events Open,
lifetime. Close, Lock and Unlock.
• Notice that not all events are valid in
all states;
– for example, if a door is opened,
you cannot lock it until you close
it.
• Also notice that a state transition can
have a guard condition attached:
– if the door is Opened, it can only
respond to the Close event if the
condition doorWay->isEmpty is
fulfilled.
State diagram example
States
• A state is a condition during the life of an object which it may
either satisfy some condition for performing some activities,
or waiting for some events to be received.
• A state has five parts:
– State Name – Name of State
– Entry – Action performed on entry to state
– Do Activity – Action performed while on the state
– Exit State – Action performed on leaving state
– Deferrable Trigger – A list of events that are not handled in that state
but, rather, are postponed and queued for handling by the object in
another state
States
Guard Condition
• State transition label – Event [Guard Condition]
• Condition is a Boolean function
– Conditions are optional on state machines
– Condition is true for finite period of time
• When event occurs, condition must be true for state transition to occur. If
condition is false, state transition does not occur.
Actions (effect)
Action is executed as a result of instantaneously of state transition. State transition label
can be expressed as the following format
• Event / action(s)
• Event [condition] / action(s)
• Entry/exit actions
Choice pseudo state
• Realizes a dynamic conditional branch. It evaluates the guards of the
triggers of its outgoing transitions to select only one outgoing transition.
• It allows splitting of transitions into multiple outgoing paths such that
the decision on which path to take.
• Example:
State Diagrams
• Dynamic Modeling
• Sequence diagrams
• State diagrams
• Practical Tips for Dynamic Modeling
• Dominant Models based on system features
Practical Tips for Dynamic Modeling
Power(on) Power(on)
Power(off) Power(off)
Power(on) Power(on)
Toy Car: Dynamic Model
Wheel
Headlight
Forward
Off power
power off
on
power power
off on
Stationary Stationary
On
power power
on
off
Backward
Toy Car: Object Model
Car
• https://www.visual-paradigm.com/
Dynamic Modeling
• Dynamic Modeling
• Sequence diagrams
• State diagrams
• Practical Tips for Dynamic Modeling
• Dominant Models based on system features
When is a Model Dominant?
• Object model:
– The system has classes with nontrivial 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 (eg. computations
consisting of many steps).
• Which model is dominant in these applications?
– Compiler
– Database system
– Spreadsheet program
Examples of Dominant Models
• Compiler:
– The functional model is most important
– The dynamic model is trivial because there is only one type input and
only a few outputs
• Is that true for IDEs?
• Database systems:
– The object model most important
– The functional model is trivial, because the purpose of the functions is
to store, organize and retrieve data
• Spreadsheet program:
– The functional model most important
– The dynamic model is interesting if the program allows computations
on a cell
– The object model is trivial.
Requirements Analysis Questions
1. What are the transformations? Functional Modeling
Create scenarios and use case diagrams
- Talk to client, observe, get historical records