COM423_5-Modeling the Behavioural View
COM423_5-Modeling the Behavioural View
● Can be
○ Generic- showing all possible scenarios for a use case, or
○ instance - depicting a single scenario within the use case.
Sequence Diagram…
● Everything in an object-oriented system is accomplished
by objects
● Objects:
○ manage data
○ move data around in the system
○ respond to queries
○ protect the system
● Objects work together by communicating or interacting
with one another
○ As such all interactions can be mapped to objects
Sequence Diagram: Example
● Step 1 & 2: Bill Creates an
Order
● Step 3: Bill adds items to
the order
● Step 4 & 5: Item checked
for availability
● Step 6 & 7: If item is
available it is added to the
order
● Step 8: End of transaction
Creating a Sequence Diagram
● Requires completed Use Case model and the Class
diagram.
● Generate sets of interactions and candidate objects for the
interactions to be modelled
● Sequence diagrams are modeled at the object level not
class level:
○ Allows for scenarios that use more than one instance of the
same class
○ Allows working at the level of facts and test data
Sequence Diagram Notation
● The Sequence diagram uses three fundamental notation
elements: objects, messages, and object lifeline
● The objects use the same notation as in the Object
diagram
○ participating objects lined up across the top of the diagram
● The object lifeline is a vertical dashed line below each
object
● A message or stimulus is usually a call, a signal, or a
response.
○ A message is represented by an arrow
○ An object can send a message to itself (self-delegation)
Sequence Diagram Extended Notation
● Sequence diagrams can be enhanced to illustrate object
activation and object termination
● Timed events: some messages are timed and if response is
not obtained within the expected time the message is
timed out
○ Represented by a circle on the arrow line and the stereotype
<<timeout>>
● Asynchronous events: messages that do not require a
response
○ Represented by a stick arrowhead instead of the solid
arrowhead
○
Sequence Diagram Extended Notation:
example
● 1: Object Activation
● 2: Object Deactivation
● 3: Timed Event
● 4: Asynchronous Event
● 5: Object Termination
Exercise: Develop a
sequence diagram
● Set the context
○ System, Use Case or Use Case
Scenario level?
● Identify actors and objects
● Set life line for each object
● Add messages
○ Review flow of events in narrative,
activity diagrams and CRC Card role
playing
● Place execution occurrence
● Validate
● Replicate for all possible scenarios
Exercise: Develop a sequence diagram
● Set the context
○ System, Use Case or
Use Case Scenario
level?
● Identify actors and
objects
● Set life line for each
object
● Add messages
○ Review flow of events
in narrative, activity
diagrams and CRC Card
role playing
● Place execution
occurrence
● Validate
● Replicate for all
possible scenarios
Solution: What’s wrong here?
15
Develop a Communication diagram
Set the
context
System,
Use Case
or Use
Case
Scenario
level?
Identify
actors,
objects and
associations
Lay out
diagram
Minimise
crossings
Add
messages
Validate
Behavioural State Machines
● A behavioral state machine is a dynamic model that shows the
different states through which a single object passes during its
life in response to events, along with its responses and actions.
○ not used for all objects
● It shows the different states of the object and what events cause
the object to change from one state to another
○ Eg New, current and former student
● Used to help understand the dynamic aspects of a single class
and how its instances evolve over time
○ As opposed to use case or use-case scenario orientation for
interaction diagrams
Behavioural State Machines…
● State of an object is defined by the value of its attributes and its
relationships with other objects at a particular point in time
○ Eg new, current or former student;
● An event is something that takes place at a certain point in time and
changes a value or values that describe an object, which, in turn,
changes the object’s state.
● A transition is a relationship that represents the movement of an
object from one state to another state
○ Can have a guard condition.
● An action is an atomic, non decomposable process that cannot be
interrupted
○ Assumed to take zero time, and they are associated with a transition.
● An activity is a nonatomic, decomposable process that can be
interrupted.
○ take long to complete and can be started and stopped by an action.
● State vs subclass!
○ Is a “Finale” state for or subclass of Student?
Behavioural State Machines… exercise
● Create a corresponding Bahavioural State Machine diagram from the
following narrative:
We track current customer status to help avoid uncollectible receivables
and identify customers worthy of preferred treatment. All customers are
initially set up as prospects, but when they place their first order, they are
upgraded to active.
If a customer doesn’t pay an invoice on time, he is placed on probation. If he
does pay on time and has ordered more than $10,000 in the previous six
months, he warrants preferred status.
Preferred status may be changed only if the customer is late on two or
more payments. Then he returns to active status rather than probation,
giving him the benefit of the doubt based on his preferred history.
Behavioural State Machines… solution
20
References
● Chapter 6 – Dennis et al (2015). Systems Analysis and
Design: An Object-oriented Approach with UML. John Wiley
& Sons