Chapter 4:
Dynamic Design
Academic Year
2021-2022
INTERACTION DIAGRAMS
2
Interaction diagrams - Objectives
• Describe how objects interact within the system...
– Show interactions between objects over time
– Present the sequence (order) and dependency of messages
exchanged between objects
• Representing certain dynamic aspects for the realization of:
– a use case
– an operation related to a use case
3
Interaction diagrams - Types
• Sequence diagram (system and object)
– System sequence diagram analysis phase
– Object sequence diagram design phase
4
OBJECT SEQUENCE DIAGRAM
5
Presentation - Reminder
• A sequence diagram is two-dimensional:
– Vertical dimension: time
• The order (sequencing) in which a message is sent is
determined by the position of the message on the
vertical axis of the diagram
• Time flows from top to bottom in this this axis
– Horizontal dimension: objects (and actors)
6
System Sequence Diagram VS
Object Oequence Diagram
Analysis
Design
Source : UML2 in practice
Example
Object Sequence Diagram of the UC "Add loan"
8
Source : UML2 Analysis and design
Key concepts
• Objects
• Lifelines
• Activation zones
• Messages
• Control structures :
- Combined fragments
9
Object, lifeline and activation zone
• Object :
• Example:
– Represents an instance :
• an actor
• a class
• Lifeline :
– Reflects the existence of an
object over a period of time.
• Activation zone :
-Represents the time during which an object is
active: executing an operation.
10
Messages (1/5)
• Objects communicate with each other via messages
• Message types:
– Synchronous message
– Asynchronous message
– Return message
– Creation message
– Destruction message
11
Messages
(2/5)
• A synchronous message translates the invocation of an
operation:
– An object asks a called object to execute an operation
– The sender object remains blocked for the duration of
the method invocation
– An object can send a message to itself to invoke
a local method: reflexive message
• Syntax : number : operationName([parameters])
12
Messages
(3/5)
• Please Note
- The operation invoked must be defined in the class relating to the
receiver object and visible in the class relating to the sender
object.
• Example:
13
Messages (4/5)
• Asynchronous message
– Sending a signal to an object
– Invoke a method without blocking the sender
• Return message
– Return a value to the calling object
• Instance creation message (synchronous)
– Invoke the object creation operation
• Instance destruction message (synchronous)
– Invoke the object destruction operation
14
Messages
(5/5)
• Example:
15
Example
• Example of translating an object sequence diagram
into Java code:
public int jouer()
{
de1.lancer();
v1=de1.lireValeur();
de2.lancer();
v2=de2.lireValeur();
v = v1 + v2;
return v;
}
Adapted from the link: http://www.wiziq.com/tutorial/23674-Diagramme-de-S-233-quence-UML
16
Control structures
(1/2)
• Combined fragments
– An interaction fragment contains an interaction
operator (example: loop, opt, alt, ref...)
• See chapter 2: dynamic analysis – system sequence diagram
• Example 1:
19
Source : Book UML2 analyse et
Control structures
(2/2)
• Example 2:
20
Source : UML2 analysis and design book
CASE STUDY
19
Example
(1/4)
• I.S. of a library for borrowing books
Use case diagram 20
Example
(2/4)
• System operations for the "Record loans" use case
are shown in the following system sequence diagram:
21
Example
(3/4)
🞎 Post-conditions
• Pre-conditions □ a loan l has been created;
– the book catalog exists and is not empty; □ the date attribute of l has been set to the date of
– the member has been recognised by the the current date;
system and has not reached the □ the returnDate attribute of l has been set to (the
maximum borrowing threshold. current date + two weeks) ;
□ l has been linked to the book b whose ISBN
attribute is set to the ISBN passed as a
parameter;
□ l has been linked to the member
concerned and to the library.
Analysis
Design
22
Example
(4/4)
Object sequence diagram for the "borrowBook" system operation:
livre
livre
p added
done
23
Software Architecture - Brief Overview
• Software architecture is the process of designing the overall
organisation of the system, including:
– The subdivision of the software into sub-systems.
– The decisions to be taken regarding their interactions.
– The determination interfaces (contracts).
• Reference model: layered model :
– Applied to applications with a graphical interface that
manipulate/handle persistent data.
– Logical architecture in 3 layers, 5 layers,...
24
Software architecture - 3-layer model
• 3-layer model
– Presentation layer
– Business layer
– Persistence layer
• Presentation layer :
– Supports interactions between users and the software
– Allows to visualize information
– Translates user commands into actions on the other
layers
• Examples: A command line, a graphical user interface, a web
browser
25
Software architecture - 3-layer model
(2/2)
• Business layer:
– Corresponds to the functional part of the application
– Describes the operations that the application performs on the
data based on user requests
– Offers application and business services to the
presentation layer by relying on the data of the
lower layer
• Persistence layer :
– Enables data storage and retrieval
– Keeps data neutral and independent of
application servers or business logic
26
Notes
• Communication between types of stereotypes
– Interface - Interface
□ Interface - Entity
– Interface - Controller
– Controller - Controller
– Controller - Entity
– Entity - Entity
• These stereotypes can be used from the analysis phase onwards
• It is not mandatory to work with these stereotypes (some design
methods advocate them).
27
Representation
28
Example
:ControllerFormation
Source : livre UML2 par la pratique
29