Software Specification 2IX20

Similar documents
The learning objectives of this chapter are the followings. At the end of this chapter, you shall

Object-Oriented Modeling. Sequence Diagram. Slides accompanying Version 1.0

Sequence Diagrams. Massimo Felici. Massimo Felici Sequence Diagrams c

Object-Interaction Diagrams: Sequence Diagrams UML

Unified Modeling Language

Object Interaction Sequence Diagrams

Introduction to Unified Modelling Language (UML)

Interaction Modelling: Sequence Diagrams

What is a Class Diagram? A diagram that shows a set of classes, interfaces, and collaborations and their relationships

What is a Class Diagram? Class Diagram. Why do we need Class Diagram? Class - Notation. Class - Semantic 04/11/51

UML Behavioral Models

In this case, the behavior of a single scenario

Lecture 21 Detailed Design Dynamic Modeling with UML

3: Modeling Behavior with UML Sequence Diagrams

CS 370 REVIEW: UML Diagrams D R. M I C H A E L J. R E A L E F A L L

UML Sequence Diagrams

Object Oriented Methods with UML. Lecture -4

CSE 403. UML Sequence Diagrams. Reading: UML Distilled Ch. 4, by M. Fowler

Class diagrams. Modeling with UML Chapter 2, part 2. Class Diagrams: details. Class diagram for a simple watch

Meltem Özturan

KF5008 Program Design & Development. Lecture 3 Sequence Diagrams

Software Specification 2IX20

Chapter 2, Modeling with UML: UML 2 Hightlights

Interactions A link message

CSE 308. UML Sequence Diagrams. Reading / Reference.

Use Case Sequence Diagram. Slide 1

Unified Modeling Language (UML) Object Diagram and Interaction Diagrams

INTRODUCTION TO UNIFIED MODELING MODEL (UML) & DFD. Slides by: Shree Jaswal

Modeling Dynamic Behavior

Specifying Precise Use Cases with Use Case Charts

Time Exceptions in Sequence Diagrams

Requirements Checking for Object-Oriented Software Design with different Unified Modelling Language (UML) notations

Sequence Diagram. r: Register s: Sale

Sequence Diagram. A UML diagram used to show how objects interact. Example:

Distributed Systems. Lec 11: Consistency Models. Slide acks: Jinyang Li, Robert Morris

Unit 5: Sequence Diagrams

Reminder from last time

CS211 Lecture: Modeling Dynamic Behaviors of Systems; Interaction Diagrams in UML

UML Fundamental. OutLine. NetFusion Tech. Co., Ltd. Jack Lee. Use-case diagram Class diagram Sequence diagram

UNIT 3

UML 2.0 UML 2.0. Scott Uk-Jin Lee. Division of Computer Science, College of Computing Hanyang University ERICA Campus

A Logical Framework for Sequence Diagram with Combined Fragments

Class diagrams. Modeling with UML Chapter 2, part 2. Class Diagrams: details. Class diagram for a simple watch

Relationships between UML Sequence Diagrams and the Topological Functioning Model for Backward Transformation

UNIT-4 Behavioral Diagrams

Sequence Diagrams. Sequence Diagrams. Version Sequence Diagrams are. History. simple powerful readable used to describe interaction sequences

Refining UML specifications. - the STAIRS method. Ragnhild Kobro Runde. Joint work with Ketil Stølen and Øystein Haugen. Ragnhild Kobro Runde

UML Sequence Diagrams for Process Views

CS211 Lecture: Modeling Dynamic Behaviors of Systems; Interaction Diagrams and Statecharts Diagrams in UML

introduction to Programming in C Department of Computer Science and Engineering Lecture No. #40 Recursion Linear Recursion

Software Modeling & Analysis

SEEM4570 System Design and Implementation Lecture 11 UML

Process Modelling. Fault Tolerant Systems Research Group. Budapest University of Technology and Economics

UNIT I. 3. Write a short notes on process view of 4+1 architecture. 4. Why is object-oriented approach superior to procedural approach?

Today s Agenda UML. CompSci 280 S Introduction to Software Development. 1.Introduction UML Diagrams. Topics: Reading:

UNIT-IV BASIC BEHAVIORAL MODELING-I

Distributed minimum spanning tree problem

Chapter 10. Object-Oriented Analysis and Modeling Using the UML. McGraw-Hill/Irwin

Applying UML & Patterns (3 rd ed.) Chapter 15

Review of the C Programming Language

Modeling Dynamic Behavior

6.001 Notes: Section 8.1

State Machine Diagrams

UML part I. UML part I 1/41

Ingegneria del Software Corso di Laurea in Informatica per il Management

Use C ases Cases 7/09

Object-Oriented Principles and Practice / C++

CS4961 Parallel Programming. Lecture 4: Data and Task Parallelism 9/3/09. Administrative. Mary Hall September 3, Going over Homework 1

Lecture 17: (Architecture V)

Software Engineering. Page 1. Objectives. Object-Behavioural Modelling. Analysis = Process + Models. Case Study: Event Identification

Lesson 11. W.C.Udwela Department of Mathematics & Computer Science

Object Oriented Modeling

What's New in UML 2.0

Draw a diagram of an empty circular queue and describe it to the reader.

System Sequence Diagrams. Based on Craig Larman, Chapter 10 and Anuradha Dharani s notes

Run-time Environments. Lecture 13. Prof. Alex Aiken Original Slides (Modified by Prof. Vijay Ganesh) Lecture 13

Object-Oriented Software Engineering Practical Software Development using UML and Java

SEEM4570 System Design and Implementation. Lecture 10 UML

COMP 354: INTRODUCTION TO SOFTWARE ENGINEERING

6/20/2018 CS5386 SOFTWARE DESIGN & ARCHITECTURE LECTURE 5: ARCHITECTURAL VIEWS C&C STYLES. Outline for Today. Architecture views C&C Views

Introduction to Model Checking

BASICS OF UML (PART-2)

4/6/2011. Model Checking. Encoding test specifications. Model Checking. Encoding test specifications. Model Checking CS 4271

Lecture 21 CIS 341: COMPILERS

Tool Support for Design Inspection: Automatic Generation of Questions

Computer Science for Engineers

Software Design and Analysis for Engineers

Enterprise Architect. User Guide Series. Testpoints. Author: Sparx Systems. Date: 30/06/2017. Version: 1.0 CREATED WITH

CSE P 501 Exam 8/5/04

Advanced Interaction

Model-based Behavioural Fuzzing. Martin Schneider (Fraunhofer FOKUS)

PROCESSES AND THREADS

Process Modelling. Fault Tolerant Systems Research Group. Budapest University of Technology and Economics

Model Based Software Timing Analysis Using Sequence Diagram for Commercial Applications

7. UML Sequence Diagrams Page 1 of 1

Notes on the Exam. Question 1. Today. Comp 104:Operating Systems Concepts 11/05/2015. Revision Lectures (separate questions and answers)

Software Engineering using Formal Methods

COSC 3351 Software Design. An Introduction to UML (I)

G Programming Languages - Fall 2012

Semantics Preservation of Sequence

Transcription:

Software Specification 2IX20 Julien Schmaltz (slides from A. Serebrenik) Lecture 05: Interaction diagrams / Sequence diagrams

This week sources Slides by Site by David Meredith, Aalborg University, DK Marie-Elise Kontro, Tampere University, FI Kirill Fakhroutdinov GE Healthcare, USA 2

Missing link» Use case diagram describes tasks that system must help actors to perform» Class diagram describes classes required to realise use cases and relationships between these classes» Interaction diagrams describe how objects interact to realise the use case scenarios» Interaction diagrams should be consistent with the corresponding class diagrams and use case diagrams / SET / W&I 26/02/15 3

UML diagram types Interactions: Chapter 17 of the UML standard. (Sequence diagrams in Chapter 17.8) 4

Interaction diagrams Sequence Diagram TODAY Communication Diagram Interaction Overview Diagram Timing Diagrams / SET / W&I 26/02/15 5

Sequence diagrams» The most common kind of Interaction Diagrams shows how actors and objects interact to realise a use case scenario focuses on the Message interchange between a number of Lifelines :A :B participants: actors, objects, etc. involved in the use case. time lifelines: represent the lifetime of a participant Notation object:class :Class = anobject:class ttp://i.stack.imgur.com/rqpvd.gif 6

Sequence diagrams» The most common kind of Interaction Diagrams shows how actors and objects interact to realise a use case scenario focuses on the Message interchange between a number of Lifelines :A sends message msg2 to :B and waits for :B s response: synchronous communication / SET / W&I response, return (optional) 26/02/15 Synchronous means that the caller waits for the callee to complete. The response is optional. 7

Sequence diagrams» The most common kind of Interaction Diagrams shows how actors and objects interact to realise a use case scenario focuses on the Message interchange between a number of Lifelines msg1 :A :B msg2 Order of participants = order of the first participation in the interaction Most of the message sends on arrows from left to right response / SET / W&I 26/02/15 8

Sequence diagrams» The most common kind of Interaction Diagrams shows how actors and objects interact to realise a use case scenario focuses on the Message interchange between a number of Lifelines msg1 :A :B msg2 response Intuition: Messages are sent to objects of classes with the corresponding operations. Class A has method msg1 Class B has method msg2 Implicit rule: A message is sent before it is received. / SET / W&I 26/02/15 9

Sequence diagrams» The most common kind of Interaction Diagrams shows how actors and objects interact to realise a use case scenario focuses on the Message interchange between a number of Lifelines msg1 :A :B msg2 Semantics: defined by a pair of two sets of traces: A set of accepted/valid traces A set of rejected/invalid traces Trace = sequence (possibly infinite) of events. / SET / W&I response 26/02/15 Each message has for semantics the trace <sendevent,receiveevent> 10

Sequence diagrams :A :B msg1 activation msg2 When a message is received by an object, a new activation is started. Activation is also known as execution specification. / SET / W&I 26/02/15 11

Sequence diagrams» We can have multiple activations of the same object: Activation resulting from message to self is slightly offset from older activation :A :B msg1 msg msg2 / SET / W&I 26/02/15 12

Sequence diagrams If there is no concurrency, exactly one object is computing at any given instant (Imaginary) horizontal line can cross only one dark area :A :B msg1 msg msg2 13

Sequence diagrams If there is no concurrency, exactly one object is computing at any given instant (Imaginary) horizontal line can cross only one dark area Activations behave as a stack msg1 :A :B msg msg2 A1 Actor A2 A1 Actor B A1 Actor 14

Sequence diagrams If there is no concurrency, exactly one object is computing at any given instant (Imaginary) horizontal line can cross only one dark area Activations behave as a stack Only actors can send messages out of the blue Objects send messages only when they have been made active by receiving a message from another participant msg1 :A :B msg msg2 A1 Actor A2 A1 Actor B A1 Actor 15

What if we want concurrency? Some communication might be asynchronous :A :B msg1 msg msg2 Note the different arrow type than for synchronous communications 16

Question for you» Messages are partially ordered (before/after) Response to msg should be received before msg2 is sent. :A :B» Why isn t the order total? msg1 msg msg2 / SET / W&I 26/02/15 17

Question for you» Messages are partially ordered (before/after) Response to msg should be received before msg2 is sent. :A :B» Why isn t the order total? independent events on different lifelines are not comparable e.g., concurrent execution resulting from asynchronous messages msg1 msg msg2 / SET / W&I 26/02/15 18

Creating and destroying objects Prince Charming getname() :Girl n = getname(): Cinderella Label: assignment of return value to a variable; value returned shown after colon destroy() Object destruction: synchronous message to the object with an X-terminating lifeline new Princess(n) Creating a new object: asynchronous message directly to the head of the new participant :Princess / SET / W&I 26/02/15 19

Summary(1) amessage(aparameter) Synchronous message. Caller waits for callee to complete before resuming execution. Message return. Receiver resumes execution. asyncmsg(aparameter) Asynchronous message. Caller does not wait for callee to complete before resuming execution. 20

Summary(2) <<create>> msg(aparam) :::A Creation of an instance of class :A. <<destroy>> msg(aparam) Destruction of an instance of the lifeline object. 21

Combined fragments and operators» Combined fragments divide a sequence diagram into different areas with different behaviour» Each combined fragment has an operator, one or more operands, and zero or more guard condition» The operator determines how operands execute» Guard conditions determine whether their operands execute 22

Not treated in this course Not treated in this course

Alternatives This is an example of a combined fragment introduced by the operator alt (alternatives). Semantics: union of the traces of the operands added to the set of valid executions of the diagram. 24

Optional behaviour Prince Charming getname() :Girl This is an example of a combined fragment introduced by the operator Opt (option). Opt n = getname() [n = Cinderella] guard Semantics: equivalent to alt with one non-empty operand and one empty operand. destroy() new Princess(n) :Princess Continue with organizing the wedding 25

Alternative and optional behaviours opt: creates a single branch if (condition) then op1() alt: creates multiple branches if (condition1) then op2() else if (condition2) then op3() else op4() 26

Loop and break loop allows you to model iteration. When the break guard condition evaluates to true, the break operand executes, and the loop terminates, 27

Loop types 28

For each element/object example 29

Combined fragments: par, seq and strict Search Google, Bing and Ask in any order, possibly parallel. Search Google, Bing and Yahoo in the strict sequential order. Search Google possibly parallel with Bing and Yahoo, but search Bing before Yahoo.» seq: Different lifelines: parallel The same lifeline: sequential / SET / W&I 26/02/15 30

Parallel (par) semantics» Traces of all possible interleaving.» Ordering within an operand is preserved. 31

Par: shorthand» Co-region: par-combined fragment with one lifeline The two fragments are equivalent / SET / W&I 26/02/15 32

Weak sequencing (seq) semantics» Set of traces with the following properties: 1. Ordering within each operand is maintained 2. Interleaving between different lifelines of different operands 3. Ordering on the same lifeline is preserved. 33

Strict sequencing (strict) semantics» Strict ordering between operands at the first level.» At lower levels: no direct comparison. 34

Combining different combined fragments» Co-region» Option» Loop» Ref (interaction use) allows to use (or call) another interaction. / SET / W&I 26/02/15 35 http://www.uml-diagrams.org/examples/sequence-examples-online-bookshop.png

Interaction use In general, referencing should be done as DiagType DiagName [(ParType:ParName)] : [: RetValType]» In practice, types are frequently omitted Checkout no parameters, no return value Debit Account (accountnumber, amount) parameters, no return value Balance Lookup (accountnumber): Real parameters, return value / SET / W&I 26/02/15 36

Interaction use / SET / W&I 26/02/15 37

Alternative way to represent a return value Gate: a message with one end connected to the sequence diagram's frame and the other end to a lifeline. / SET / W&I 26/02/15 38

Question for you» How to model exception handling in sequence diagram?» NB: UML provides neither notation to model exception handling in sequence diagrams nor any reasoning why it is absent.» Still, what would be your solution? / SET / W&I 26/02/15 39

Question for you» How to model exception handling in sequence diagram?» NB: UML provides neither notation to model exception handling in sequence diagrams nor any reasoning why it is absent.» Still, what would be your solution? Combined fragments alt/break / SET / W&I 26/02/15 40

Negative / invalid behaviours The interaction operator neg describes combined fragment of traces that are defined to be negative (invalid). Negative traces are the traces which occur when the system has failed. All interaction fragments that are different from the negative are considered positive, meaning that they describe traces that are valid and should be possible. Should we receive back timeout message, it means the system has failed. 41

Neg: another example One cannot open the microwave door when it is cooking. Also notice the from 1 to time loop. / SET / W&I 26/02/15 http://www.zicomi.com/combinedfragmentnegative.jsp 42

Not treated in this course Not treated in this course

State invariant Attribute t of Task should have value complete A transaction on SavingsAccount is permitted only if the balance remains positive. 44

Duration constraint / SET / W&I 26/02/15 45

Summary of the syntax http://www.uml-diagrams.org/sequence-diagrams.html 46

Building sequence diagrams» Set the context» Identify participants that should interact to realize the use-case scenario / to respond to messages arriving at the interface. Place the initiator of the interaction on the left of the diagram Multiple objects of the same class: name each» Set the lifeline for each participant» Add messages by drawing arrows Order messages from left to right, top to bottom Show how they are passed from one object to another Include any parameters in parentheses Exclude obvious return values» Add activations to each participant s lifeline» Validate the sequence diagram / SET / W&I 26/02/15 47

Validation» Recall: Interaction diagrams should be consistent with the corresponding class diagrams and use case diagrams» Rule: Objects in [sd] should be instances of classes in [cd]» Rule: Name of the message [sd] should match an operation in the receiver s class [cd] ATM +withdrawcash(accountnumber, amount) http://www.ibm.com/developerworks/rational/library/3101.html 48

Validation» Recall: Interaction diagrams should be consistent with the corresponding class diagrams and use case diagrams» Rule: Objects in [sd] should be instances of classes in [cd]» Rule: Name of the message [sd] should match an operation in the receiver s class [cd] The message is a getter! +name Girl 49

Validation» Recall: Interaction diagrams should be consistent with the corresponding class diagrams and use case diagrams» Rule: Objects in [sd] should be instances of classes in [cd]» Rule: Name of the message [sd] should match an operation in the receiver s class [cd]» Rule: If a message is sent from A to B [sd] then there should be an association from the class of A to the class of B [cd]» Rule: If use-case A generalizes use-case B [ucd] then the sequence diagram of A should be a subgraph of the sequence diagram of B [sd]. 50

Validation» Recall: Interaction diagrams should be consistent with the corresponding class diagrams and use case diagrams» Briand et al. mention 120 consistency rules http://squall.sce.carleton.ca/pubs/tech_report/ TR_SCE-03-01.pdf» Active research domain around 2005 Prototype implementations Inconsistency detection vs. inconsistency resolution 51

UML diagram types: so far / SET / W&I 26/02/15 52