SE Lecture 05 Dynamic Diagrams PDF

Summary

These lecture notes provide an overview of UML dynamic diagrams in software engineering. The presentation covers sequence diagrams, communication diagrams, state diagrams, and activity diagrams. Topics include messages, lifelines, events, and control nodes.

Full Transcript

Software Engineering UML dynamic diagrams Aleksander Jarzębowicz Anna Bobkowska Department of Software Engineering ETI Faculty, Gdańsk University of Technology slide: 1 Software Engineering Modeling of obj...

Software Engineering UML dynamic diagrams Aleksander Jarzębowicz Anna Bobkowska Department of Software Engineering ETI Faculty, Gdańsk University of Technology slide: 1 Software Engineering Modeling of object-oriented system’s dynamics System’s behavior observable from the external perspective Communication between objects (exchange of messages) and its results Activities and actions conducted jointly by objects in order to deliver system’s services Changes of object’s state slide: 2 Software Engineering Concepts used to describe dynamics Timing consecution – next, after, later Causality – cause-consequence, event-reaction – because, therefore, in response to Circumstances, conditions – repeat when conditions are fulfilled – if... then... slide: 3 Software Engineering Diagrams in UML ver. 2.5 Diagram Structural Behavioral diagram diagram Class Object Package Use case Interaction State machine Activity diagram diagram diagram diagram diagram diagram diagram Profile diagram Composite Component Deployment structure diagram diagram diagram Sequence Communication Interaction Timing diagram diagram diagram overview diagram slide: 4 Software Engineering Dynamic (behavioral) diagrams Interaction diagrams (group) – Sequence diagram – Communication diagram – Timing diagram – Interaction overview diagram State machine diagram Activity diagram slide: 5 Software Engineering Interaction diagrams Sequence diagram concerns multiple objects: – describes exchange of messages between objects in order to deliver a given function/service – presents the interaction from the point of view of the flow of time Communication diagram concerns multiple objects: – describes exchange of messages between objects in order to deliver a given function/service – presents the interaction focusing on relationships between objects – is less popular than sequence diagram, but used e.g. in descriptions of design patterns slide: 6 Software Engineering Sequence diagram Purpose: to clearly visualize how does an exchange of messages between objects happen over time lifeline :Computer :Printer Basic elements: – Lifelines 1:Print(file) – Messages message 2:Printed execution - object is active (executes some behavior or waits for response) slide: 7 Software Engineering Messages A message – is an information passed to another object – has a sender and a recipient (the arrow points at recipient) Message types – simple (no distinction of message type) – distinction into 2 types: synchronous message the sender invokes an operation of the recipient and awaits until that operation is finished (only after that the sender can resume its activity) return of control after the operation is finished (optional) asynchronous message the sender sends a message and immediately after that resumes its activity, without waiting until the message is received and processed slide: 8 Software Engineering Sequence diagram – example 1 GUI ProductCatalogue Product User set criteria() search() loop search(criteria) [for all products] getInfo() product data() filter() alt list of products found() loop, iteration [products matching criteria found] display results() [no products matching search criteria found] no results() alternative, inform about lack of results() exception slide: 9 Software Engineering Elements of sequence diagrams Duration of a message (time required for its passing) Alternative sequences A message from an object to itself Creating a new object Deleting an object slide: 10 Software Engineering Interaction fragments Source: D. Ramenska et al. Property Specification Made Easy: Harnessing the Power of Model Checking in UML Designs, IFIP FORTE 2014 conference slide: 11 Software Engineering Operators used in interaction fragments sd — name of the sequence diagram ref — reference to another diagram loop — the fragment may execute multiple times alt — alternative multiple fragments: only the one whose condition is true will execute opt — optional, the fragment executes only if the supplied condition is true par — each fragment is run in parallel (there are more operators, but rarely used, so they are not listed here) slide: 12 Software Engineering Duration and time Usually, a message is shown as a horizontal line. However, it is possible 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 (which may be important in modeling real-time systems). Source: Sparxsystems, UML 2 Tutorial slide: 13 Software Engineering Sequence diagram – example 2 Rental store, customer checking history of rentals and reservations :CustomerGUI thisCustomer: :Rental :Reservation Customer :Customer checkAccount(customerID) getPersonalData() getHistory() loop getRentalInfo() loop getReservationInfo() showAccountHistory (rentals, reservations) slide: 14 Software Engineering Communication diagrams Purpose: to show the exchange of messages together with a static structure of communicating objects, including the links between them [Something like an object diagram (or its part) with addition of messages] Almost the same contents as sequence diagrams, just visualized in different way! slide: 15 Software Engineering Elements of communication diagrams F104/2019: Inv oice Objects and links John Doe: Customer F238/2019: Inv oice Messages Conditions 1.1: *getDetails() Iterations F238/2019: Inv oice :Inv oice item Nested messaged John Doe: 2: getInfo() F238/2019: Inv oice 2.1: *getDetails() :Inv oice item Customer slide: 16 Software Engineering Communication diagram – example 1 Curricula 1: getCourseList() 1.1: *getName() 2.2: getFile() 2: [course selected]:getDetailedInfo() 2.1: getInfo() 3: [course selected]:getStudentList() 3.1: getStudents() GUI Course Lecturer 3.2: *getIDandName() Student slide: 17 Software Engineering Communication diagram – example 2 :Rental 1.5: showRentalsReservations(rentals, reservations) 1.3: *getRentalInfo() 1.1: getPersonalData() 1.2: getHistory() :CustomerGUI :Customer 1: checkAccount() :Customer 2: cancelReservations() 2.1: () 1.4: *getReservationInfo() :Reserv ation SelectedReserv ation: Reserv ation slide: 18 Software Engineering State machine diagrams and activity diagrams State machine diagram describes one object (of a given class) and shows: possible states of the object actions undertaken in particular states transitions between states and their causes Activity diagram describes one or many objects and shows: – activities conducted by objects – control flow of such activities expressed by sequence and conditions of the flow slide: 19 Software Engineering Elements of state machine diagram State machine diagram for Bill (Check) object: Event payment Unpaid Paid cancel State Transition Initial state Cancelled destroy Final state slide: 20 Software Engineering State machine diagram State – is determined by values of object’s attributes and by object’s links to other objects – determines how the object reacts on various events – in a given state, the object can be idle (and wait for events) or can execute some actions/activities Event – something that is important for an object in a given state – an event can cause object’s transition to another state Transition – a directed relationship between states State1 State2 event [guard condition] /action slide: 21 Software Engineering Description of a state and a transition State name event [guard] /action Entry/ Do/ Exit/ Event – an event causing the transition Guard – a condition that must be fulfilled for the transition to happen Action – additional action invoked as a result of the transition Entry - behavior performed upon entry to the state Do - ongoing behavior, performed as long as the object is in the state Exit - behavior performed upon exit from the state slide: 22 Software Engineering State machine diagram - example slide: 23 Software Engineering Class diagram and state machine diagram slide: 24 Software Engineering State machine diagram – concurrent states A complex meter that counts two physical quantities: class Meter A : Integer; B : Integer; method IncA(); method IncB(); method Init(); method Stop() end slide: 25 Software Engineering State machine diagram – concurrent states Two or more „spaces” of states, usually independent from each other slide: 26 Software Engineering State machine diagram – composite states slide: 27 Software Engineering State machine diagram – exit point Source: Sparxsystems UML 2 tutorial This element implies the exit of current composite state slide: 28 Software Engineering State machine example – a copy of a film in video rental shop Activ e withdraw In store In back office put back rent return Rented Before return date Ov erdue [currentDate > setReturnDate] remove Remov ed slide: 29 Software Engineering State machine example: phone call slide: 30 Software Engineering Different state machines (1) A distinction should be made between: – objects in real-time systems (elevator, meter, watch) that react to events in real time and also their states can reflect physical conditions – objects representing information items that change state as result of e.g. a workflow related to such item It is important e.g. for an elevator to distinguish whether it is moving or not, is its door open/closed/opening/closing etc. However, it does not make much sense for a shopping order to define its states e.g. „being read”, „being saved” etc. – much more essential states that can be identified are related e.g. to order’s acceptance or order’s completion (workflow) slide: 31 Software Engineering Different state machines (2) floor button pressed [doorway Waiting Closing door empty] Elevator: door opened door closed destination floor reached Opening door Mov ing process [all items available] New Accepted Completed accept Shopping order: reject process [some items process [all items available] unavailable] /give discount confirm shipment Rej ected Delayed Sent slide: 32 Software Engineering Activity diagram Activity diagram shows the workflow from its starting point to its finish point. Its building blocks are activities and actions. Transitions between them occur right after an activity/action is completed. The diagram also specifies decision nodes that result in different paths of that workflow and other control nodes. Activity – a more complex behavior, sequence of actions Action – a simple behavior, single, atomic operation e.g. read, save, calculation Decisions – choice of workflow path based on some condition(s) Partitions – indicate which objects are responsible for which activities/actions slide: 33 Software Engineering Activity diagram Shows the workflow of activities/actions done in order to use some functionality of the system Can also be used to model business processes from application domain slide: 34 Software Engineering Control nodes slide: 35 Software Engineering Activity diagram with concurrent threads Meter with a display: slide: 36 Software Engineering Activity diagram with partitions and concurrent threads Meter and its display: slide: 37 Software Engineering Activity diagram with partitions, concurrent threads and object flow Meter, its display and measurement result: slide: 38 Software Engineering Interdependencies between UML diagrams class mój use ca... class mój use ca... Class2 Class1 association Use Case Actor Class3 sd Interaction GUI :Class1 :Class2 Actor stm StateMachine k1() State1 State2 zd2 k2() [w1] /a1 k3() Initial zd1 zd2 zd1 k4() State3 rk4() k5() Final rk5() k6() slide: 39

Use Quizgecko on...
Browser
Browser