Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graphical Systems Modeling with UML / SysML Sequence diagrams

Similar presentations


Presentation on theme: "Graphical Systems Modeling with UML / SysML Sequence diagrams"— Presentation transcript:

1 Graphical Systems Modeling with UML / SysML Sequence diagrams
ca. 30 min. © Piotr Ciskowski

2 State machine diagrams – lecture plan:
Overview GO Basic elements GO Advanced elements GO Combined fragments GO Summary GO Examples GO lecture plan

3 Perspectives - views: Dynamic View Logical view Use case view
architecture class diagram object diagram composite structure diagram package diagram behavior sequence diagram activity diagram state machine diagram interaction overview diagram communication diagram timing diagram package diagram Dynamic View Logical view Use case view Deployment View system scope & functionality use case diagram package diagram Implementation View hardware deployment diagram package diagram software component diagram package diagram

4 Sequence diagram describes interactions between instances as sequences of messages passed between them documents functionality of a use case

5 Sequence diagram describes interactions between instances as sequences of messages passed between them documents functionality of a use case shows: flow of control order and location of performed operations exchange of messages between objects – chronologically logic of methods and services

6 Sequence diagram describes interactions between instances as sequences of messages passed between them documents functionality of a use case shows: flow of control order and location of performed operations exchange of messages between objects – chronologically logic of methods and services close to code

7 Sequence diagram describes interactions between instances as sequences of messages passed between them documents functionality of a use case shows: flow of control order and location of performed operations exchange of messages between objects – chronologically logic of methods and services close to code horizontally - classifiers’ instances vertically - time

8 Sequence diagram describes interactions between instances as sequences of messages passed between them documents functionality of a use case shows: flow of control order and location of performed operations exchange of messages between objects – chronologically logic of methods and services close to code horizontally - classifiers’ instances - statics vertically - time - dynamics

9 Sequence diagram types of diagrams – levels of detail / abstraction:
conceptual - general scope - evident interactions

10 Sequence diagram types of diagrams – levels of detail / abstraction:
conceptual - general scope - evident interactions implementational - very precise - all types of elements - main flow and all alternative flows - complete specification - for programmers / CASE tools instance - implementational for a certain scenario

11 Sequence diagram basic elements

12 Basic elements: objects, actors (classifiers’ instances) lifelines
As lifeline is always linked to one element (actor or object), some people treat it as one and call the pair (object, lifeline) a lifeline A lifeline usually has a rectangle containing: object name (and its class) class name (anonymous object) „self” – classifier which own the sequence diagram image: Sparx Systems – UML 2 Tutorial

13 Basic elements: objects, actors (classifiers’ instances) lifelines
messages

14 Basic elements: objects, actors (classifiers’ instances) lifelines
messages activation - focus of control - object active / inactive

15 Basic elements: objects, actors (classifiers’ instances) lifelines
messages in this diagram anonymous objects of Computer and Server classes interact image: Wikipedia

16 Basic elements: objects, actor, lifelines, messages:
Client PINpad Screen ATMinterface BankSystem ChipCard getPIN() enterPIN verifyPIN() showOperations() checkBalance checkAccountBalance() showBalance() in this diagram the notation of objects (their names) is rather conceptual

17 Sequence diagram advanced elements

18 Advanced elements on detailed implementation diagrams:
different types of messages creating and destroying objects conditions messages to self (self messages) duration and time constraints combined fragments interaction uses gates

19 Advanced elements Messages

20 Messages synchronous call asynchronous call asynchronous signal reply
synchronious send message, suspend execution, wait for response asynchronious no waiting for response reply sending back the focus of control to the sender after a synchronious call optional image: Sparx Systems – UML 2 Tutorial

21 Messages synchronous call asynchronous call asynchronous signal reply
self image: Sparx Systems – UML 2 Tutorial

22 Messages synchronous call asynchronous call asynchronous signal reply
self create delete image: Sparx Systems – UML 2 Tutorial

23 Messages synchronous call asynchronous call asynchronous signal reply
self create delete create message may have a «create» stereotype image:

24 Messages synchronous call asynchronous call asynchronous signal reply
self create delete lost found Two types of messages used in conceptual phase: lost receiver temporarily unknown to be completed later found sender out of the diagram sent by a phenomenon image: Sparx Systems – UML 2 Tutorial

25 Advanced elements Other elements

26 Other elements conditions - mesage executed if condition satisfied - usually one message – one condition Buyer IAuction [bidPrice > minBidPrice] : joinAuction() example based on: Wrycza et al., Język UML 2.0 w modelowaniu… (modified)

27 Other elements conditions
iterations - multiple execution * < operation > * [ < iteration specification > ] < operation > IProjectManager WorkerDatabase *[worker := 1..n] : assignSpecialist() example based on: Wrycza et al., Język UML 2.0 w modelowaniu… (modified)

28 Other elements conditions iterations
forks - at least two disjoint conditions Seller IUserPanel ProductCatalogue Auction cancelAuction(reason) [reason = withdrawArticle] : deleteArticle() [reason = cancelAcution] : endAuction() example based on: Wrycza et al., Język UML 2.0 w modelowaniu… (modified)

29 Other elements forks - at least two disjoint conditions - with receiver’s lifeline split Buyer CFDcontract Broker Bank closePosition() updateValue() [currentValue > nominalValue]:closePosition() transferProfit() [currentValue < nominalValue]:closePosition() deductLoss() transferDeposit() confirmClosedPosition() CFD – Contract For Difference – kontrakt różnic kursowych – main type of instruments on forex markets example based on: Wrycza et al., Język UML 2.0 w modelowaniu… (modified)

30 Other elements conditions iterations forks
constraints (time & duration) Duration and Time Constraints: By default, a message is shown as a horizontal line Since the lifeline represents the passage of time down the screen, when modelling a real-time system, or even a time-bound business process, it can be important to consider the length of time it takes to perform actions By setting a duration constraint for a message, the message will be shown as a sloping line. image: Sparx Systems – UML 2 Tutorial

31 Advanced elements Combined fragments

32 Combined fragments combined fragment - part of sequence diagram enclosed in a frame executed under specific circumstances - adds procedural logic sequence diagrams are not intended for showing complex procedural logic but there are a number of mechanisms that do allow for adding a degree of procedural logic to diagrams – combined fragments

33 Combined fragments combined fragment - part of sequence diagram enclosed in a frame executed under specific circumstances - adds procedural logic operator - how to interpret operand - what to do sequence diagrams are not intended for showing complex procedural logic but there are a number of mechanisms that do allow for adding a degree of procedural logic to diagrams – combined fragments

34 Combined fragments alt - alternative - if–then-else - switch
execution of one and only one of a few operands image:

35 Combined fragments opt - option - alt with only one operand
optional execution of the (only one) operand image:

36 Combined fragments break - breaking or exceptional scenario - performed instead of other interactions only one operand on execution of this operand, all other interactions of the enclosing interaction fragment are ignored in this case all remainding operations in the loop would be ignored image:

37 Combined fragments loop - iteration loop (n) loop (min,max) loop
operand is repeated for a specific number of times: strictly n times lower and upper number of iterations no parameters = infinite loop images:

38 Combined fragments neg - invalid series of messages
invalid actions – exceptions that must be served e.g.: arythmetic operation error index out of range invalid data type stack overflow etc. After www-uml-diagrams.org: 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 In this example: Should we receive back timeout message, it means the system has failed image:

39 Combined fragments par - parallel, concurrent processing
all operands are processed concurrently image:

40 Combined fragments par - simplified notation
image:

41 Combined fragments critical - critical section - highest priority - object „reservation” critical section – gets the highest priority during execution of the whole interaction instance classifiers, enclosed in critical section, are not allowed to take part in other interactions interactions surrounding the critical section, not disturbing it, may be processed concurently After A critical region is a region with traces that cannot be interleaved by other occurrence specifications (on the lifelines covered by the region) This means that the region is treated atomically by the enclosing fragment and can't be interleaved, e.g. by parallel operator In this example: Add() or remove() could be called in parallel, but each one should run as a critical region. image:

42 Combined fragments consider - ignore consider { <messages> } ignore { <messages> } consider defines which messages should be considered within the combined fragment = all others will be ignored ignore defines which messages are of no interest if they appear in the current context seems obscure – but may be used to specify a test of an existing system (at runtime messages ignored during tests will be executed) images:

43 Combined fragments strict - strict order (sequencing)
the order, in which the messages are executed – cannot be changed image:

44 Combined fragments seq - weak sequencing
encloses a number of sequences for which all the messages must be processed in a preceding segment before the following segment can start, but which does not impose any sequencing within a segment on messages that don’t share a lifeline messages on different lifelines – may be executed in any order After The ordering of occurrence specifications within each of the operands is maintained Occurrence specifications on different lifelines from different operands may come in any order Occurrence specifications on the same lifeline from different operands are ordered such that an occurrence specification of the first operand comes before that of the second operand In this example: Search Google possibly parallel with Bing and Yahoo, but search Bing before Yahoo image:

45 Combined fragments ref - other interaction use
allows to use (call) another interaction reference to another diagram simplifies large and complex interaction diagrams allows for reusing some interaction between several other interactions referenced interaction has formal gates interaction use provides a set of actual gates that must match the formal gates of the interaction images:

46 Combined fragments: alt - alternative opt - option
break - breaking or exceptional scenario loop - iteration neg - invalid actions par - parallel processing critical - critical section, highest priority consider, ignore strict, seq - strict order, weak sequencing ref - reference to other interaction

47 Summary

48 Sequence diagram Summary: image:

49 Sequence diagram Steps: analyze use cas scenario
identify classifiers to take part in the interaction create conceptual diagram: classifiers’ instances – horizontally ordered messages - vertically execution boxes create implementation diagram: all other details, advanced elements and full specifications needed create instance diagram

50 Examples

51 Examples for discussion Facebook User Authentication in a Web application source: after An example of sequence diagram which shows how Facebook (FB) user could be authenticated in a web application to allow access to his/her FB resources. Facebook uses OAuth 2.0 protocol framework which enables web application (called "client"), which is usually not the FB resource owner but is acting on the FB user's behalf, to request access to resources controlled by the FB user and hosted by the FB server. Instead of using the FB user credentials to access protected resources, the web application obtains an access token. Web application should be registered by Facebook to have an application ID (client_id) and secret (client_secret). When request to some protected Facebook resources is received, web browser ("user agent") is redirected to Facebook's authorization server with application ID and the URL the user should be redirected back to after the authorization process. User receives back Request for Permission form. If the user authorizes the application to get his/her data, Facebook authorization server redirects back to the URI that was specified before together with authorization code ("verification string"). The authorization code can be exchanged by web application for an OAuth access token. If web application obtains the access token for a FB user, it can perform authorized requests on behalf of that FB user by including the access token in the Facebook Graph API requests. If the user did not authorize web application, Facebook issues redirect request to the URI specified before, and adds the error_reason parameter to notify the web application that authorization request was denied.

52 Examples … source: www.uml-diagrams.org
more examples at Online Bookshop Submit Comments to Pluck using AJAX

53 Examples for discussion Collaboration „Rent item”. source: www
Examples for discussion Collaboration „Rent item” source: this example is just to show that there is another tool – only for sequence diagrams: trace modeler


Download ppt "Graphical Systems Modeling with UML / SysML Sequence diagrams"

Similar presentations


Ads by Google