Software Engineering Lectures 13 & 14: State Machines (PDF)

Summary

This document presents lecture notes on state machines in software engineering. It covers state diagrams, actions, transitions, and states (including pseudostates), focusing on how they're used in software design. The material connects state machines to Java code examples, covering the dynamics and behavior of reactive objects through the use of states and transitions.

Full Transcript

Lectures 13 and 14 State machines Course 2024/2025 Software Engineering 2024/2025 Why do computer scientists never tell lies? Software Engineering 2024/2025 UML - State Machine Diagrams Software Engineering 2024/2025 3 Or...

Lectures 13 and 14 State machines Course 2024/2025 Software Engineering 2024/2025 Why do computer scientists never tell lies? Software Engineering 2024/2025 UML - State Machine Diagrams Software Engineering 2024/2025 3 Originally State charts David Harel Based on Finite state machines to describe large, complex, reactive systems behaviour, bring: Broadcast (communication) Orthogonality (concurrency) Depth (abstraction, nesting of statecharts) Memory (History mechanism) Software Engineering 2024/2025 4 State Charts and their role in OO design Software Engineering 2024/2025 Guido Zockoll, Axel Scheithauer & Marcel Douwe Dekker, “History of Object-Oriented Modeling Languages”, 2009 5 State machines are defined during design State machines are usually defined during the design workflow Create a state machine to understand a complex life cycle or behaviour ○ If it is too simple, it may not pay off to do so Particularly useful in real-time, embedded systems, where objects may have complex behavior and life cycles Software Engineering 2024/2025 6 A state diagram models the dynamic behaviour of a reactive object Goal: to model behaviour (dynamic) Use for modelling objects (or systems) with complex behaviour (that would otherwise be hard to understand) Use when the control is deeply influenced by external events Don’t use when several objects are involved ○ Interaction diagrams are more adequate, in that scenario Software Engineering 2024/2025 7 Key elements in state machine diagrams State ○ A condition or situation during the life cycle of an object during which it satisfies some condition, performs some activity, or waits for some event Event ○ The specification of a noteworthy occurrence that has location in time and space Transition ○ The movement from a state to another in response to an event Software Engineering 2024/2025 8 A reactive object provides context for a state machine Responds to external events May generate and respond to internal events Has a life cycle modelled as a progression of states, transitions, and events May have current behaviour that depends on past behaviour Software Engineering 2024/2025 9 State machines model the behaviour of classifiers, such as Classes Use cases Subsystems Entire systems Software Engineering 2024/2025 10 Behavioural vs protocol state machines Behavioural state machines Protocol state machines Specify the implementation of a Do not specify the implementation of behaviour this behaviour, only use order and results of operations calls Can be used to specify the behaviour of classifiers with implementation Can be used to specify the protocol for all classifier, including those States can specify one or more without implementation actions that execute when the state is entered States can’t specify actions Denoted by the keyword {protocol} after the state machine name Software Engineering 2024/2025 11 State machine diagrams Software Engineering 2024/2025 12 Example of correspondence to Java code Fragment (incomplete) of a State Machine of a Lecture Hall: More detailed version for implementation: class LectureHall { private boolean free; occupy() public void occupy() { free = false; free = free = } true false public void free() { release() free = true; } } Software Engineering 2024/2025 13 State is a semantically significant condition of an object A condition or situation during the life cycle of an object during which: ○ It satisfies some condition ○ Performs some activity ○ or waits for some event The state consists of: ○ Name ○ Actions, or activities ○ Internal transitions ○ Sub-states ○ Deferred events (to delay the answer to certain events) Software Engineering 2024/2025 14 Actions are instantaneous and uninterruptible Each action in a state is associated with an internal transition triggered by an event ○ In this example, two special actions, entry and exit are modelled The entry event occurs immediately after entering a state and causes the event action to execute The exit event is the last thing that happens on exiting the state and causes the associated event action action syntax: eventName/ someAction to execute activity syntax: do/ someActivity Software Engineering 2024/2025 15 Internal transitions capture that some transition within the same state has happened Each internal transition captures an event which is noteworthy but does not cause a state transition ○ In this example, it is relevant to know that a key was pressed, or that help is being internal displayed, but none of those cause leaving the transitions state EnteringPassword Software Engineering 2024/2025 16 Actions are instantaneous and uninterruptible Each action in a state is associated with an internal transition triggered by an event entry and exit actions are associated with two special events (entry and exit) The entry event occurs when the state is entered The exit event is the last thing to occur when the state is exited action syntax: eventName/ someAction activity syntax: do/ someActivity Software Engineering 2024/2025 17 Activities take finite time to execute and are interruptible Each activity takes a finite time to execute and is interruptible by an event The keyword do indicates an activity Unlike actions, activities can be interrupted before they finish processing action syntax: eventName/ someAction activity syntax: do/ someActivity Software Engineering 2024/2025 18 Types of States Real States ○ The ones described before Pseudostates ○ Those are transient. The system cannot remain in a pseudostate. They are not states in the actual sense but rather control structures that enable more complex states and state transitions. Initial state and Terminate node Decision node Junction Parallelization and synchronization nodes History Entry and exit points Software Engineering 2024/2025 19 Initial state Has no incoming edges and usually one outgoing edge which leads to the first “real” state. If multiple outgoing edges are used, their guard conditions must be mutually exclusive and cover all possible cases to ensure that exactly one target state is reached. As soon as the system is in the initial state, it immediately — that is, without consuming any time—switches to the next state. Software Engineering 2024/2025 20 Terminate and Final state nodes If a terminate node is reached in a flow, the state machine terminates and the modeled object ceases to exist Final state is not pseudostate and has at least one incoming edge and no outgoing edges. It marks the end of the sequence of states. The object can remain in a final state permanently. Software Engineering 2024/2025 21 Transitions show movement between states Relationship between two states, indicating that an object in the source state will execute certain actions and transition to a target state, when a given set of events occur and certain conditions are met Example: On (event1 or event2), if (guardCondition) then perform anAction and enter state B. Software Engineering 2024/2025 22 A transition occurs when 1. An object is in its source state 2. An event occurs 3. If a guard condition is true a. An action is executed b. The object changes to the target state Software Engineering 2024/2025 23 Transitions have three optional elements Zero or more events ○ These specify external or internal occurrences that can trigger the transition Zero or one guard condition ○ This is a boolean expression that must evaluate to true before the transition can occur Zero or more actions ○ This is a piece of work associated with the transition and occurs when the transition fires Software Engineering 2024/2025 24 Transitions in state protocols have a slightly different syntax There is no action, as we are specifying a protocol rather than an implementation The guard condition is replaced by pre and post conditions ○ Notice how the precondition is placed before the slash while the postcondition is placed after the slash Software Engineering 2024/2025 25 What if the transition has no event? If a transition has no event it is an automatic transition Automatic transitions ○ do not wait for an event ○ fire when their guard conditions or preconditions are true Software Engineering 2024/2025 26 Junction pseudo-states join or branch transitions Junction pseudo-states represent points where transitions merge or branch They may have one or more input transitions and one or more output transitions Software Engineering 2024/2025 27 Protect junction pseudo-states with mutually exclusive guard conditions Note how the junction pseudo-state has two inputs and two mutually exclusive guards, [extend] and [!extend] Note also the junction pseudo-state before the OnLoan state Software Engineering 2024/2025 28 The choice pseudo-state directs the flow through the state machine according to guard conditions Software Engineering 2024/2025 29 Upon receiving the acceptPayment event, the BankLoan object transitions to one of three states Software Engineering 2024/2025 30 The choice pseudo-state guard conditions are mutually exclusive, so that only one transition is fired Software Engineering 2024/2025 31 Attention In (c) the first transition increments b an only then the guards are evaluated while in (d) the guards are evaluated first and then b is incremented Software Engineering 2024/2025 32 Junction points can also help tidying up your diagram, to increase its understandability Without the junction With the junction Software Engineering 2024/2025 33 Events trigger transitions event Software Engineering 2024/2025 34 The same event (e.g. checkmate), when on different states, may lead to different outcomes Software Engineering 2024/2025 35 There are four kinds of events Call events Signal events Change events Time events Software Engineering 2024/2025 36 A call event is a request for a specific operation to be invoked on an instance of the context class Software Engineering 2024/2025 37 Call events A call event should have the same signature as an operation of the context class of the state machine ○ This applies to internal and external call operations Receiving a call operation triggers the operation to execute You can specify a sequence of actions, separated by “;”, for a call event ○ these specify the semantics of the operation and can use attributes and operations of the context class and may have a return type - the call event has a value of the same return type Software Engineering 2024/2025 38 A signal event is a one-way asynchronous communication between objects A signal event is a package of information sent asynchronously between objects ○ It usually does not have operations, as its purpose is to carry information Software Engineering 2024/2025 39 SimpleBankAccount sends a signal when withdrawal is rejected Software Engineering 2024/2025 40 A signal receipt accepts the signal as a parameter and leads to a new state Software Engineering 2024/2025 41 Change events occur when a Boolean expression changes value from false to true A change event implies continuously testing the Boolean condition while in state. Change events are positive-edge triggered - they are triggered whenever the condition changes from false to true. Software Engineering 2024/2025 42 Time events occur in response to time Time events are usually indicated with the keywords when, or after: when specifies a particular time in which the event is triggered. [e.g. when (date = 2018/12/07)] after specifies a threshold time after which the event is triggered. [e.g. after (3 months)] Software Engineering 2024/2025 43 Composite states Dealing with model complexity Software Engineering 2024/2025 44 Initial and process are substates of On Initial and Process “inherit” the switchOff If a composite state is active, only one of its substates is active at any point in time. Software Engineering 2024/2025 45 Orthogonal states - Composite states that contain one or more nested submachines To achieve concurrent states, a composite state can be divided into two or more regions, whereby one state of each region is always active at any point in time Each submachine exists in its own region within the composite state Software Engineering 2024/2025 46 Regions are independent, concurrent parts of a composite state - they are activated synchronously Each region can also have a final state. In this case, the completion event of the higher level state is not created until the final state is reached in all regions. Software Engineering 2024/2025 47 Entering and exiting composite states A transition to the boundary of the orthogonal state activates the initial states of all regions To enter in a composed state, you need to This is an equivalent alternative to have an initial substate in each region representing this model, using pseudo-states “fork” and “join”. Software Engineering 2024/2025 48 Nested substates inherit all of the transitions of their containing superstates If the composite state has a transition, each of its nested states also has this transition Software Engineering 2024/2025 49 The final pseudo-state of a submachine only applies within that region If the second submachine reaches its final state first, that region will terminate, but the first region will continue to execute In contrast, when the terminate pseudo-state of the first region is reached, the whole composite state stops Software Engineering 2024/2025 50 Nested states can also be composite states This mechanism should be used with parsimony ○ When possible keep nesting to two or three levels Beyond that, the state machine tends to become hard to read and understand To keep the state machine simple, you may hide the details of a composite state ○ Use the composition icon to denote that a given state is a composite state Software Engineering 2024/2025 51 Entry and Exit points: type of encapsulation mechanism If an external transition leads to this entry point, the execution can be started with the desired state without the external transition having to know the structure of the composite state. If the composite state is not to be ended as usual when the final state is reached but instead through the ending of another state, you can model exit points in the same way. Software Engineering 2024/2025 52 Simple vs orthogonal composite spaces Simple composite state ○ One region only Orthogonal composite state ○ Two or more regions Software Engineering 2024/2025 53 Simple composite states contain a single nested state machine Software Engineering 2024/2025 54 Orthogonal composite states contain two or more nested state machines that execute concurrently When you enter an orthogonal composite state, all its submachines start at once (this is an implicit fork) You can exit an orthogonal composite state ○ When all its submachines finish (this is an implicit join) ○ When one of its submachines transitions to a state outside the supermachine, usually via an exit pseudo-state This does not cause a join - no synchronization among submachines The remaining submachines simply abort Software Engineering 2024/2025 55 example Software Engineering 2024/2025 56 Initializing composite state: synchronization between submachines The initialization only finishes after both InitializingFireSensors and InitializingSecuritySensors finish. Software Engineering 2024/2025 57 Monitoring composite state: no synchronization between the two submachines If a fire is detected, we exit the monitoring state. Similarly, if an intruder is detected, we also exit the monitoring state. Software Engineering 2024/2025 58 A submachine state references another state machine (recorded in a separate diagram) Semantically equivalent to a composite state Submachine states are used to simplify complex state machines Submachine states provide a reuse mechanism Syntax: state name: name of referenced state machine diagram Software Engineering 2024/2025 59 Consider this machine state Software Engineering 2024/2025 60 Now, we can reuse the VerifyingUser submachine state Software Engineering 2024/2025 61 It is as if the contents of the submachine state are replaced by VerifyingUser Software Engineering 2024/2025 62 You can use attribute values to communicate asynchronously between concurrent submachines When we set paidFor in the top submachine, this enables the transition in the bottom one! Software Engineering 2024/2025 63 You can also use Synch state synchronization points to synchronize different regions (in combination with fork and join) We can only start the project after Lab1 is done. Software Engineering 2024/2025 64 Memory in State Machines Software Engineering 2024/2025 65 Shallow history remembers the last substate you were in at the same level as the shallow history pseudo-state Software Engineering 2024/2025 66 Shallow history remembers the last substate you were in at the same level as the shallow history pseudo-state Software Engineering 2024/2025 67 Deep history remembers the last substate you were in at the same level, or lower, than the deep history pseudo-state Software Engineering 2024/2025 68 Examples Software Engineering 2024/2025 69 Examples with memory (history state) Software Engineering 2024/2025 70 What happens with H ? It remembers and restores the previously active state at the same nesting depth Assume that E is active and event e1 occurs. G becomes active. When G is active and event e5 occurs, the next state might be B, C, or F (depending on which was active before - in our example, it would be C) The next state is not E, even if it was previously active, because H does not remember it. Software Engineering 2024/2025 71 What happens with H*? H* remembers and restores the previously active state at any depth Assuming that E is active and event e1 occurs, G is the next active state If now e3 occurs, C and more concretely E becomes the next active state Software Engineering 2024/2025 72 SEQUENCE OF EVENTS: e4 -> e5-> e1 http://elearning.uml.ac.at/submitQuiz Software Engineering 2024/2025 73 SEQUENCE OF EVENTS: e4 -> e5-> e1 http://elearning.uml.ac.at/submitQuiz Software Engineering 2024/2025 74 SEQUENCE OF EVENTS: e4 -> e5-> e1 http://elearning.uml.ac.at/submitQuiz Software Engineering 2024/2025 75 SEQUENCE OF EVENTS: e4 -> e5-> e1 http://elearning.uml.ac.at/submitQuiz Software Engineering 2024/2025 76 SEQUENCE OF EVENTS: e4 -> e5-> e1 http://elearning.uml.ac.at/submitQuiz Software Engineering 2024/2025 77 SEQUENCE OF EVENTS: e4 -> e5-> e1 http://elearning.uml.ac.at/submitQuiz Software Engineering 2024/2025 78 SEQUENCE OF EVENTS: e4 -> e5-> e1 http://elearning.uml.ac.at/submitQuiz Software Engineering 2024/2025 79 SEQUENCE OF EVENTS: e4 -> e5-> e1 http://elearning.uml.ac.at/submitQuiz Software Engineering 2024/2025 80 Did you really understand State Machines? Test yourself at: http://elearning.uml.ac.at/ Software Engineering 2024/2025 81 References Jim Arlow and Ila Neustadt, “UML 2 and the Unified Process”, Second Edition, Addison-Wesley 2006 Software Engineering 2024/2025 82 Why do computer scientists never tell lies? Because they can't stand unhandled exceptions. Software Engineering 2024/2025 Lecture 17 and 18 Sequence Diagrams Course 2024/2025 Software Engineering 2024/2025 UML Interaction Diagrams 2 Software Engineering 2024/2025 What is an interaction? The the purpose of the state machine diagram (to be discussed the lectures) is to model the intra-object behavior ○ that is, the life cycle of Intra-object behavior The inter-object behavior ○ are interactions between the objects in a system An interaction specifies how messages and data are exchanged between interaction partners. Software Engineering 2024/2025 3 Message An interaction describes the interplay between multiple interaction partners and comprises a sequence of messages. The sending or receipt Message of a message can be triggered by the occurrence of certain events. Predefined constraints specify any necessary preconditions that must be met for successful interactions. Software Engineering 2024/2025 4 UML Interaction Diagrams From the several Interaction Diagrams supported by UML we will study the UML Sequence Diagrams. 5 Software Engineering 2024/2025 Main Elements in an Interaction: Lifeline Lifeline – a single participant in an interaction Software Engineering 2024/2025 6 Main Elements in an Interaction: Lifeline Lifeline – a single participant in an interaction ○ Name – used to refer to the lifeline Software Engineering 2024/2025 7 Main Elements in an Interaction: Lifeline Lifeline – a single participant in an interaction ○ Name – used to refer to the lifeline ○ Selector – Boolean expression to specify a particular participant instance (if it does not exist, the participant can be any instance of the corresponding type) Software Engineering 2024/2025 8 Main Elements in an Interaction: Lifeline Lifeline – a single participant in an interaction ○ Name – used to refer to the lifeline ○ Selector – Boolean expression to specify a particular participant instance (if it does not exist, the participant can be any instance of the corresponding type) ○ Type – Classifier name that the lifeline represents Software Engineering 2024/2025 9 Main Elements in the interaction: Lifeline A lifeline represents how a classifier instance participates in the interaction Lifelines are represented with the same icon as their type and have a vertical dashed “tail” when used in sequence diagrams Software Engineering 2024/2025 10 Main Elements in an Interaction: Message A message represents a specific communication between two lifelines in an interaction This may include: ○ Calling an operation - a call message ○ Creating and Destroying instances ○ Sending a signal Software Engineering 2024/2025 11 Exchanging Messages in a Sequence Diagram Software Engineering 2024/2025 12 Messages kinds Synchronous (sender waits for answer) Asynchronous (sender does not wait for answer) Return (returns focus of control) Create (new lifeline) Destroy (lifeline) Found (unknown origin) Lost (unknown destiny) Software Engineering 2024/2025 13 Synchronous and Asynchronous Messages Asynchronous Synchronous Software Engineering 2024/2025 14 Message kinds Software Engineering 2024/2025 15 On the order of messages The vertical time axis determines the sequence of event occurrences on a lifeline, although this does not define the order of event occurrences on different lifelines Software Engineering 2024/2025 16 Time-consuming message If necessary to express that time elapses between the sending and the receipt of a message, you model the message as a diagonal line in the sequence diagram rather than a horizontal line. Software Engineering 2024/2025 17 Example: Consider the AddCourse use case Software Engineering 2024/2025 18 Analysis class diagram corresponding to the use case AddCourse Software Engineering 2024/2025 19 The Sequence Diagram (sd) AddCourse realizes the behavior specified in the AddCourse use case Software Engineering 2024/2025 20 The DeleteCourse use case Software Engineering 2024/2025 21 This second example illustrates self-delegation and object destruction Software Engineering 2024/2025 22 Combined fragments and operators Combined fragments divide a sequence diagram into different regions with different behaviors Fragments are composed of: ○ An operator Determines how the operands execute ○ One or two operands ○ Zero or more guard conditions Determine if operands are executed, or not Software Engineering 2024/2025 23 Combined fragments divide a sequence diagram into different areas with different behavior If there is no guard, then [true] is assumed as the Guard default value. Software Engineering 2024/2025 24 Types of combined fragments And also … Reference (ref) Software Engineering 2024/2025 25 Alternative (alt) creates multiple mutually exclusive branches (as in a switch) The alternative to execute depends on the value of the guard ○ The guard “else” is supported - its operand executes only if none of the other guard conditions is true Software Engineering 2024/2025 26 Option (opt) creates a single branch Special case of an alternative where only one of the operands may execute ○ Similar to an if… then, without any else Software Engineering 2024/2025 27 Alt and Opt - example of nesting Software Engineering 2024/2025 28 Sequence diagram for this use case Software Engineering 2024/2025 29 Iteration (loop) Optional guard: [, , ] ○ loop min, max [condition] works as follows: loop min times while the condition is true loop (max – min) times A loop without max, min, or a condition is an infinite loop If only min is given, then max = min The condition is usually a Boolean expression, but may also be arbitrary text, provided the intent is clear ○ In this case, automatic code generation will be harder… :-( Software Engineering 2024/2025 30 Common loop idioms Software Engineering 2024/2025 31 Interruption (break) When the break guard condition evaluates to true, the break operand executes and the loop terminates The break represents an alternative which is executed in turn of the rest of the fragment ○ Similar to a break in a cycle ○ The rest of the loop after the break does not execute! Example: break enclosing loop if y > 0 the interaction continues in the next higher level fragment Software Engineering 2024/2025 32 loop over a collection to find a specific element Software Engineering 2024/2025 33 Reusing sequences Sometimes, a particular sequence of sent message occurs very often Instead of drawing that sequence over and over again, we should reuse it ○ drawing the same sequence over and over again is tiresome and error-prone Interaction occurrences are references to another interaction When an interaction occurrence is placed into an interaction, the flow of the interaction it references is included at that point Software Engineering 2024/2025 34 Consider the following analysis class diagram Software Engineering 2024/2025 35 … and the LogOnRegistrar use case Software Engineering 2024/2025 36 The use case could be refined into the LogOnRegistrar sequence diagram Software Engineering 2024/2025 37 For a lot of much more interesting use cases, we can now reference the LogOnRegistrar Software Engineering 2024/2025 38 Second example - We can use this to create reusable sequence diagrams for common interactions Student Software Engineering 2024/2025 39 We can use this to create reusable sequence diagrams for common interactions Course Software Engineering 2024/2025 40 We can use this to create reusable sequence diagrams for common interactions Student Course Software Engineering 2024/2025 41 Gates are inputs and outputs of interactions Use a gate when you want an interaction to be triggered by a lifeline that is not part of the interaction Software Engineering 2024/2025 42 Gates provide added flexibility in the reuse of interactions: use them when some of the messages arrive from the output and you don’t know in advance where they might come from Software Engineering 2024/2025 43 Gates can also be used in messages to the same lifeline Software Engineering 2024/2025 44 Continuations allow an interaction fragment to terminate in such a way it can be continued by another fragment Depending on which option is selected, the interaction terminates at one of the three continuations Software Engineering 2024/2025 45 You can use continuations to decouple interactions (here, GetCourseOption from HandleCourseOption) Software Engineering 2024/2025 46 Parallel (par) All the operands execute concurrently (interleaved) and not necessarily true parallelism ○ Search Google, Bing and Ask in any order, possibly in parallel Software Engineering 2024/2025 47 Parallel (par) All the operands execute concurrently (interleaved) ○ a->b->c->d ○ a->b->d->c ○ a->c->b->d ○ a->c->d->b ○ a->d->b->c ○ a->d->c->b ○ c->a->b->d ○ c->a->d->b ○ c->d->a->b ○ d->a->b->c ○ d->a->c->b ○ d->c->a->b (any sequence where b is after a) Software Engineering 2024/2025 48 Critical region (critical) The execution traces may not be interleaved with events of other lifelines ○ The execution is performed without any interruption a->b->c b->a->c c->a->b c->b->a (any sequence where the sub-sequences a->b, or b->a, are not interrupted) Software Engineering 2024/2025 49 Critical region (critical) The operand executes atomically without interruption Software Engineering 2024/2025 50 Weak sequence (seq) The operands execute in parallel in the different lifelines, with a restriction: events received in the same lifeline, originated by different operands, occur in the same sequence as the one of the operands ○ Search google, possibly in parallel with bing and Yahoo, but search bing before yahoo (because they are in the same lifeline) Software Engineering 2024/2025 51 Weak sequence (seq) 1. The sequence of events within an operand is fixed. 2. Events within different operands on different lifelines have no defined sequence. 3. Events within different operands on the same lifeline use the sequence of the operands. p!, p*, t!, t*, q!, r!, r*, q* p!, t!, t*, p*, q!, r!, r*, q* Software Engineering 2024/2025 52 Weak sequence (seq) Software Engineering 2024/2025 53 Strong sequence (strict) The operands execute in strict sequence ○ Search Google, Bing, and Yahoo, in strict sequential order Software Engineering 2024/2025 54 Strong sequence (strict) The operands execute in strict sequence ○ a -> b -> c Software Engineering 2024/2025 55 Strong sequence (strict) ○ Not possible to print before registering Software Engineering 2024/2025 56 Time constraints To express that an event takes place between 12:00 and 13:00, for example, you would use the form {12:00..13:00} Relative times are specified with reference to a starting event using the keyword after, for example, {after(5sec)} Software Engineering 2024/2025 57 Advanced operators Software Engineering 2024/2025 58 Negative (neg) Identifies sequences that may not occur ○ If we receive back a timeout message, this means the system has failed Software Engineering 2024/2025 59 Ignore (ignore) List messages that are deliberately omitted ○ Ignore get() and set() messages, if any Software Engineering 2024/2025 60 Consider (consider) List messages that were intentionally included ○ Consider only add() or remove() messages, ignore any other Software Engineering 2024/2025 61 Assertion (assert) Represents the only valid behavior in a given point in the interaction ○ commit() message should occur at this point, following with evaluation of state invariant ○ any other continuation would be wrong Software Engineering 2024/2025 62 Consider a security system embedded system Software Engineering 2024/2025 63 Use case DeactivateSystem Software Engineering 2024/2025 64 Use case ActivateAll Software Engineering 2024/2025 65 Use case TriggerSensor Software Engineering 2024/2025 66 Classes Software Engineering 2024/2025 67 Sequence diagram for ActivateAll Both operands of par execute in parallel A critical section represents an atomic behavior that can’t be interrupted Both loops have a semantics of a repeat… until - they execute once, set the variable used in their condition, and then repeat while it is true The fire alarm must always have precedence over the intruder alarm Software Engineering 2024/2025 68 If we have several fire sensors, we have to loop and check each of them Software Engineering 2024/2025 69 Building Design Sequence Diagrams: a step-by-step guide The “25 de Abril” Bridge Toll case study Software Engineering 2024/2025 70 Rule #1: when starting, the system is seen as a black box Sequence Diagram with the system represented as a black box Software Engineering 2024/2025 71 Rule #2: All messages from/to actors pass by a Boundary object Sequence Diagram with an interface object Software Engineering 2024/2025 72 Rule #3: we need control objects for complex functionalities Sequence Diagram with a boundary object (interfaces the system with the actors) and a control object Software Engineering 2024/2025 73 Rule #4: Control objects centralize the processing involving entity objects Sequence Diagram with an interface object and a control object Software Engineering 2024/2025 74 Rule #5: We can have several Boundary objects simultaneously Software Engineering 2024/2025 75 Rule #6: Boundary objects can be hierarchically connected Software Engineering 2024/2025 76 You can also use an alternative notation for stereotyping your lifelines Software Engineering 2024/2025 77 You are given this sequence diagram. Which of the following traces are possible? a) c-> a -> b b) c-> b -> a c) a-> b -> c d) b-> a -> c e) a-> c -> b f) b-> c -> a Software Engineering 2024/2025 78 You are given this sequence diagram. Which of the following traces are possible? a) c-> a -> b b) c-> b -> a c) a-> b -> c d) b-> a -> c e) a-> c -> b f) b-> c -> a b can’t be before a! Software Engineering 2024/2025 79 You are given this sequence diagram. Which of the following traces are possible? a) a-> c -> b -> d b) a-> b-> d -> c c) a-> b-> c -> d d) b-> d -> a -> c Software Engineering 2024/2025 80 You are given this sequence diagram. Which of the following traces are possible? a) a-> c -> b -> d b) a-> b-> d -> c c) a-> b-> c -> d d) b-> d -> a -> c Software Engineering 2024/2025 81 You are given this sequence diagram. Which of the following traces are possible? a) a-> b -> c -> e -> d b) c-> d -> a -> b -> e c) a-> c -> d -> b -> e d) e-> a -> b -> c -> d e) c-> a -> e -> d -> b f) a-> b ->e -> d -> c Software Engineering 2024/2025 82 You are given this sequence diagram. Which of the following traces are possible? a) a-> b -> c -> e -> d b) c-> d -> a -> b -> e c) a-> c -> d -> b -> e d) e-> a -> b -> c -> d e) c-> a -> e -> d -> b f) a-> b ->e -> d -> c Software Engineering 2024/2025 83 Software Engineering 2024/2025 84 Software Engineering 2024/2025 85 Software Engineering 2024/2025 86 Software Engineering 2024/2025 87 Which are valid sequences? Software Engineering 2024/2025 88 Which are valid sequences? Software Engineering 2024/2025 89 Which are valid sequences? Software Engineering 2024/2025 90 Which are valid sequences? Software Engineering 2024/2025 91 Lecture 19 and 20 Activity Diagrams Course 2024/2025 Software Engineering 2024/2025 UML Activity Diagrams Software Engineering 2024/2025 2 A bit of history on Activity Diagrams Gentle warning… neglecting the next couple of slides has been a source for HUGE misunderstandings concerning Activity Diagrams Software Engineering 2024/2025 3 On the origins of activity diagrams Often called “Object-Oriented flowcharts”, inspired in business processes languages You model a process as an activity consisting on nodes connected by edges (so, a graph) In UML 1.*, activity graphs were a special case of state machines ○ Every state had an entry action that specified some process, or function, that occurred when the state was entered. Guess what? UML 1.* is no more since, like, 2005. :-) The semantics behind activity diagrams changed dramatically. You will find a huge amount of outdated resources online on activity diagrams, even if they were written recently by extremely famous people. Beware. They get to be incredibly wrong, quite often. A lot of them are still stuck in 2004, disseminating long deprecated notions that inevitably lead to deadlocks and other nasty things. We often ask about this in midterms and exams and find out many “old souls”, too. Beware… Software Engineering 2024/2025 4 Activity Diagrams in UML 2.* Completely new semantics based on Petri Nets ○ The Petri Net formalism provides greater flexibility in modelling different types of flow ○ There is now a clear distinction in UML between activity diagrams and state machines Tokens Transitions Places Carl Adam Petri [1926 , 2010] Software Engineering 2024/2025 5 Activities can be attached to any modelling element Focuses on modeling procedural processing aspects of a system It specifies the control flow and data flow between various steps —the actions— required to implement an activity Support for modeling both object-oriented systems and non-object-oriented systems Frequently used for describing: ○ Use cases ○ Operations in the form of individual instructions ○ Functions of a business process Activity diagrams should focus in communicating a particular aspect of a system’s dynamic behavior Software Engineering 2024/2025 6 Common usages for activity diagrams During analysis ○ To model the flow in a use case in a graphical way that is easy for the stakeholders to understand ○ To model the flow between use cases, through the interaction overview diagram During design ○ To model the details of an operation ○ To model the details of an algorithm In business modelling ○ To model a business process As with any other UML diagram, remember that one of its functions is to communicate to stakeholders. Like use cases, activity diagrams can be effective in communication, if we keep them as simple as possible. Software Engineering 2024/2025 7 Activities are networks of nodes connected by edges Action nodes - represent discrete units of work Control nodes - control the flow through the activity Object nodes - represent objects used in the activity Edges - to show how to flow from one node to another. The passing can be prevented by a guard evaluating to false. Activities can have parameters (arranged overlapping at the boundary of an activity) Software Engineering 2024/2025 8 Activities are networks of nodes connected by edges control flows - represent the flow of control through the activity object flows - represent the flow of objects through the activity Software Engineering 2024/2025 9 The send letter activity Send letter precondition: know topic for letter postcondition: letter sent to address Software Engineering 2024/2025 10 Activities may have preconditions that must hold, before the activity can start Send letter precondition: know topic for letter postcondition: letter sent to address Software Engineering 2024/2025 11 Activities may have postconditions that must hold, after the activity ends Send letter precondition: know topic for letter postcondition: letter sent to address Software Engineering 2024/2025 12 Activities start with a single control node: the initial node Send letter precondition: know topic for letter postcondition: letter sent to address Software Engineering 2024/2025 13 Control transitions from an origin to a destination node through a control flow Send letter precondition: know topic for letter postcondition: letter sent to address Software Engineering 2024/2025 14 Then, the control transitions to the action node Write Letter Send letter precondition: know topic for letter postcondition: letter sent to address An action node indicates a piece of work or behavior that is atomic from the perspective of the containing activity. Execution time is considered negligible. Software Engineering 2024/2025 15 Then, the control transitions to the action node Address letter Send letter precondition: know topic for letter postcondition: letter sent to address An action node indicates a piece of work or behavior that is atomic from the perspective of the containing activity. Execution time is considered negligible. Software Engineering 2024/2025 16 And then, the control transitions to the action node Post letter Send letter precondition: know topic for letter postcondition: letter sent to address An action node indicates a piece of work or behavior that is atomic from the perspective of the containing activity. Execution time is considered negligible. Software Engineering 2024/2025 17 One or more final nodes indicate where the activity terminates Send letter precondition: know topic for letter postcondition: letter sent to address Software Engineering 2024/2025 18 Each action node may have its own pre- and postconditions Send letter precondition: know topic for letter postcondition: letter sent to address Software Engineering 2024/2025 19 Use cases express behavior as an interaction between actors and the system Use case: PaySalesTax ID: 1 PaySalesTax Brief description: Pay Sales Tax to the Tax Authority at the end of the business precondition: It is the end of the business quarter quarter postcondition: The Tax Authority receives the Primary Actors: Time correct amount of Sales Tax Secondary Actors: TaxAuthority Preconditions: 1. It is the end of the business quarter Main flow: 1. The use case starts when it is the end of the business quarter 2. The system determines the amount of sales tax owed to the tax authority 3. The system sends an electronic payment to the tax authority Postconditions: 1. The Tax Authority receives the correct amount of Sales Tax Alternative flows: none Software Engineering 2024/2025 20 Software Engineering 2024/2025 21 The token game describes the flow of tokens around a network of nodes and edges according to specific rules Tokens may represent ○ the flow of control ○ an object ○ some data The state of the system is determined by the disposition of its tokens Tokens are moved from a source to a target node across an edge ○ Token movement is subject to conditions and only occurs when all those conditions are satisfied Software Engineering 2024/2025 22 Tokens are moved from a source to a target node across an edge Token movement is subject to conditions and only occurs when all those conditions are satisfied Conditions vary depending on node type Send letter precondition: know topic for letter postcondition: letter sent to address Software Engineering 2024/2025 23 Tokens are moved from a source to a target node across an edge Token movement is subject to conditions and only occurs when all those conditions are satisfied Conditions vary depending on node type Send letter precondition: know topic for letter postcondition: letter sent to address Software Engineering 2024/2025 24 Tokens are moved from a source to a target node across an edge Token movement is subject to conditions and only occurs when all those conditions are satisfied Conditions vary depending on node type Send letter precondition: know topic for letter postcondition: letter sent to address Software Engineering 2024/2025 25 Tokens are moved from a source to a target node across an edge Token movement is subject to conditions and only occurs when all those conditions are satisfied Conditions vary depending on node type Send letter precondition: know topic for letter postcondition: letter sent to address Software Engineering 2024/2025 26 Tokens are moved from a source to a target node across an edge Token movement is subject to conditions and only occurs when all those conditions are satisfied Conditions vary depending on node type Send letter precondition: know topic for letter postcondition: letter sent to address Software Engineering 2024/2025 27 Tokens are moved from a source to a target node across an edge Token movement is subject to conditions and only occurs when all those conditions are satisfied Conditions vary depending on node type Send letter precondition: know topic for letter postcondition: letter sent to address Software Engineering 2024/2025 28 Tokens are moved from a source to a target node across an edge Token movement is subject to conditions and only occurs when all those conditions are satisfied Conditions vary depending on node type Send letter precondition: know topic for letter postcondition: letter sent to address Software Engineering 2024/2025 29 Action nodes Software Engineering 2024/2025 30 Action nodes execute when ○ There is a token simultaneously on each of their input edges (an implicit join) AND ○ the input tokens satisfy all of the action node local preconditions Software Engineering 2024/2025 31 Action nodes offer control tokens on all their output edges ○ This is an implicit fork ○ Activity diagrams are inherently concurrent Software Engineering 2024/2025 32 There are 4 action node kinds Software Engineering 2024/2025 33 Call action node Software Engineering 2024/2025 34 An action can call another activity Address letter Here, Address letter invokes the Address letter activity Software Engineering 2024/2025 35 An action can call a behavior Direct invocation of a behavior of the context of the activity, without specifying any particular operation Software Engineering 2024/2025 36 An action can call an operation There is a standard operation syntax for it You can specify the details of the operation in a particular programming language, which is useful for code generation from activity diagrams You can refer to features of the activity by using the keyword self Software Engineering 2024/2025 37 The send signal action node represents the asynchronous sending of a signal The send signal action is started when there is a token simultaneously in all its input edges ○ If the signal has pins, it must receive an input of the right type for each of its attributes When the action executes, a signal object is constructed and sent. The target is not usually specified, but if you need to specify it, you can pass it into the send signal action on an input pin The signal may be parameterized during its creation The sending action does not wait for confirmation of signal receipt - it is asynchronous The action ends and control tokens are offered on its output edges Software Engineering 2024/2025 38 The accept event action node waits for the receipt of an event of the right type The accept event action node has zero or one input edges Its action is started by an incoming control edge, or, if it has no incoming edge, it is started when its owning activity starts The action waits for the receipt of an event of the specified type. This event is known as the trigger. When the action receives an event trigger of the right type, it outputs a token that describes the event. If the event was a signal event, the token is a signal. The action continues to accept events while the activity executes Software Engineering 2024/2025 39 Sending/receiving signals The Process Order Activity originates the sending of the Request Payment Signal The Ship Order waits for receiving the Payment Confirmed Signal Software Engineering 2024/2025 40 Accept time event action nodes respond to time The time event action node has a time expression and generates a time event when the expression becomes true A time expression may refer to: ○ an event in time (e.g. end of business year) ○ a point in time (e.g. on July 25, 2004) ○ a duration (wait 5 seconds) Software Engineering 2024/2025 41 When the owning activity is triggered, the node becomes active and will generate a time event whenever its expression becomes true Software Engineering 2024/2025 42 If the node has an input edge, it only becomes active when it receives a token and only then will it generate a time event whenever its expression becomes true Software Engineering 2024/2025 43 Control nodes Software Engineering 2024/2025 44 Control nodes Initial node Activity final node Flow final node Decision node Merge node Fork node Join node Software Engineering 2024/2025 45 Initial node indicates where the activity starts Indicates where the flow starts when an activity is invoked There may be more than one initial node ○ Flows start at all the initial nodes simultaneously ○ Flows execute concurrently These nodes are not mandatory, provided there is some other way of starting the activity: ○ Accept event action ○ Accept time event action ○ Activity parameter node Software Engineering 2024/2025 46 Activity final node terminates an activity The activity final node stops all flows within an activity An activity may have several activity final nodes ○ The first one to be activated stops all the other flows and the activity itself In this example, receiving a TerminateEvent signal ends the whole activity (i.e. all existing flows) Software Engineering 2024/2025 47 Flow final node terminates a specific flow within the activity The activity flow final node stops one of the flows within the activity ○ Other flows are unaffected and continue In this example, when receiving a NewsEvent signal, the signal is passed to the action Display news. Control then flows a flow final node, terminating this flow, but not the whole Show news activity. Software Engineering 2024/2025 48 Decision node allows the output edge whose guard is true to be traversed A decision node has one input edge and two or more output edges A token arriving to the decision node is offered to all output edges but it will traverse at most one of them Each output edge is protected by a guard condition ○ The edge will accept the token if the guard condition evaluates to true The guard conditions must be mutually exclusive, so that only one can be evaluated to true and therefore crossed ○ If they are not mutually exclusive, the behavior of the decision node is undefined. The keyword else can be used as an alternative if none of the other guard conditions evaluated to true Software Engineering 2024/2025 49 Decision node may have a stereotyped note Optionally, this may have a note stereotyped as encoding a decision condition whose result is then used by the guard conditions on the edges Software Engineering 2024/2025 50 Merge node copies input tokens to its single output edge Merge nodes have two or more input edges and one single output edge They merge all incoming flows into a single outgoing flow All tokens offered on the incoming edges are offered on the outgoing edge, with no modification of the flow, or of the tokens Software Engineering 2024/2025 51 If you want to confuse other stakeholders, try this - breaks the ice in meetings, but not in a nice way Using a single symbol for a merge, followed by a decision node is legal, but not a good idea. Separate them to increase the understandability of your model. Software Engineering 2024/2025 52 A fork node splits the flow into multiple concurrent flows A fork node has one incoming edge and two or more outgoing edges. Tokens arriving from the incoming edge are replicated and offered on all of the outgoing edges simultaneously Outgoing edges may have guard conditions ○ Tokens can only traverse the outgoing edges when the guard condition is true ○ No mutually exclusive guard conditions can be defined in the guard conditions of the output edges of the fork Software Engineering 2024/2025 53 A join node synchronizes multiple concurrent nodes Join nodes have multiple input edges and a single output edge They synchronize flows by offering a token on their single output when there is a token in all incoming edges ○ This performs a logical AND on the input edges Make sure all input edges to the join will receive a token (no mutually exclusive guards, remember?) May optionally have a join specification to modify its semantics Software Engineering 2024/2025 54 Concurrency model Trace: A, { (B,C) || (X,Y) }, Z where || is the parallel composition operator and , is the sequence composition operator Software Engineering 2024/2025 55 Object nodes Software Engineering 2024/2025 56 Object flows represent the movement of objects around an activity The object node represents an instance of a particular classifier ○ Or of a specialization (subclass) of that classifier The input and output edges of an object node are object flows Software Engineering 2024/2025 57 Object nodes as buffers Object nodes act as buffers where object tokens can reside while waiting to be accepted by other nodes By default, these buffers have infinite capacity However, you can define an upper bound to limit this capacity You can also define the ordering policy within the object node ○ FIFO (First In, First Out) - this is the default ○ LIFO (Last In, First Out) - this is the alternative Software Engineering 2024/2025 58 Object nodes as filtered buffers Object nodes may have a selection behavior, acting as filters ○ In this example, the object node selects only orders created in December and offers the corresponding object tokens to the output edge using the default ordering (FIFO) Software Engineering 2024/2025 59 Object nodes can represent objects in a particular state In this example, an order processing activity accepts Order objects in the state Open and dispatches them, in the state Dispatched Software Engineering 2024/2025 60 Activity parameters are object nodes input to, or output from, an activity Use object nodes to provide inputs or outputs for the activity These nodes should overlap the activity frame Input nodes have one or more output edges into the activity Output nodes have one or more input edges from the activity Software Engineering 2024/2025 61 Example 62 Software Engineering 2024/2025 Pins are object nodes that represent one input, or one output, from an action Presentation aside, they have the same semantics as object nodes Software Engineering 2024/2025 63 Activity edged connectors can be used to prevent cluttering - but avoid this if possible! Software Engineering 2024/2025 64 Activity partitions Software Engineering 2024/2025 65 An activity partition (aka swimlane) represents a high-level grouping of related actions A partition allows you to group nodes and edges of an activity based on common properties. Activities can be divided into partitions by using horizontal, vertical, or curved lines The semantics is defined by the modeller; common examples include: ○ use cases ○ classes ○ components ○ organizational modeling ○ roles ○... Software Engineering 2024/2025 66 Several organization alternatives for swimlanes partitioning Software Engineering 2024/2025 67 Examples Software Engineering 2024/2025 68 You can also annotate the nodes (use this only if the visual swimlanes are impractical for your model) Software Engineering 2024/2025 69 Each set of partitions should have a single dimension Software Engineering 2024/2025 70 We can also organize swimlanes horizontally Software Engineering 2024/2025 71 Interruptible Activity Regions Software Engineering 2024/2025 72 Interruptible activity regions Regions of an activity that are interrupted when a token traverses an interrupting edge ○ When the region is interrupted, all flows within it are immediately aborted Mechanism for modelling interrupts and asynchronous events Two alternative notations: Software Engineering 2024/2025 73 Exception handling If an error occurs during the execution of an action, the execution is terminated In this situation, there is no guarantee that the action will deliver the expected output. If an action has an exception handler for a specific error situation, this exception handler is activated when an exception occurs. Using an exception handler, you can define how the system is to react in a specific error situation e. Software Engineering 2024/2025 74 Example: Log on Software Engineering 2024/2025 75 Style matters Software Engineering 2024/2025 76 A few notes on style A good activity diagram ○ Communicates a particular perspective of the system’s dynamics ○ Shows only the elements which are relevant for understanding that perspective ○ Offers only the level of detail to be understood (you can always use mechanisms to help like call behaviour, connectors, etc) ○ Is not excessively minimalistic to a point where the stakeholders reading it are uninformed about the activity’s semantics ○ Model the flow from the top left corner to the bottom ○ If modelling use cases: Do not model communication among external actors (you should be concentrated in the system behaviour) Usually the main actor’s swimlane (that triggers the use case) is located on the left of the diagram Software Engineering 2024/2025 77 Hints and tips Use a name for the activity that communicates well its purpose Use verbs as names for the activities Start by modelling the main purpose of the system (the main flow), and only then you may be concerned with the alternative flows (including dealing with exceptions, errors, etc) Use the layout of your diagram to minimize lines crossing each other, where possible Make sure your activity diagram is consistent with all the other views of your model Software Engineering 2024/2025 78 Let us get back to Use cases for a moment Software Engineering 2024/2025 79 Specifying the abstract use case Find Product Use case: Find product ID: 1 Description: The buyer tries to find a product in the system. Main actor: Buyer Secondary actors: None Pre-conditions: None Main flow: 1. The case study starts when the buyer selects the option to find a product. 2. The system asks the buyer to define the search criteria to use. 3. The buyer introduces the search criteria. 4. The system searches products satisfying the buyer’s search criteria. 5. If the system finds products matching criteria for products 5.1. The system shows the user a list of products matching the search criteria. 6. Else 6.1. The system shows the buyer a message indicating no product was found. Post-conditions: None Alternative flows: None Software Engineering 2024/2025 80 Specifying the Find Book specialization Use case: Find Book ID: 2 Specializes: Find Product Description: The buyer searches a book in the system. Main Actor: Buyer Secondary Actors: None Pre-conditions: None Main flow: 1. (o1.) The use case starts when the buyer selects the option to find a book. 2. (o2.) The system asks the buyer to to define the search criteria to use, which should include the author, title, ISBN, or topic. 3. The buyer introduces the search criteria. 4. (o4.) The system searches for books satisfying the buyers search criteria. 5. (o5.) If the system finds books matching the search criteria for books 5.1. The system shows its best seller. 5.2. (o5.1.) The systems shows a list with up to 5 books matching the search criteria. 5.3. For each book, the system presents the author, title, price and ISBN 5.4. While there are more books to show, the system offers the buyer the possibility of requesting the next page with more books. 6. Else 6.1. The system shows its best seller. 6.2. (6.1.) The system shows the buyer a message indicating no product was found. Post-conditions: None Alternative flows: None Software Engineering 2024/2025 81 Create an activity diagram for the Find Book use case Use case: Find Book ID: 2 Specializes: Find Product Description: The buyer searches a book in the system. Main Actor: Buyer Secondary Actors: None Pre-conditions: None Main flow: 1. (o1.) The use case starts when the buyer selects the option to find a book. 2. (o2.) The system asks the buyer to to define the search criteria to use, which should include the author, title, ISBN, or topic. 3. The buyer introduces the search criteria. 4. (o4.) The system searches for books satisfying the buyers search criteria. 5. (o5.) If the system finds books matching the search criteria for books 5.1. The system shows its best seller. 5.2. (o5.1.) The systems shows a list with up to 5 books matching the search criteria. 5.3. For each book, the system presents the author, title, price and ISBN 5.4. While there are more books to show, the system offers the buyer the possibility of requesting the next page with more books. 6. Else 6.1. The system shows its best seller. 6.2. (6.1.) The system shows the buyer a message indicating no product was found. Post-conditions: None Alternative flows: None Software Engineering 2024/2025 82 Time for a few exercises Note: all of the following diagrams have problems. Do NOT use them as examples of how to model. They are not. Far from it. Software Engineering 2024/2025 83 What is wrong with this activity diagram? Software Engineering 2024/2025 84 What is wrong with this activity diagram? With a Deadlock here. Software Engineering 2024/2025 85 What is wrong with this activity diagram? With a Deadlock here. Deadlocks there and there. Software Engineering 2024/2025 86 What is wrong with this activity diagram? With a Deadlock here. Deadlocks there and there. Undefined transitions everywhere. Software Engineering 2024/2025 87 What is wrong with this model? Software Engineering 2024/2025 88 What is wrong with this model? Software Engineering 2024/2025 89 What is wrong with this model? Software Engineering 2024/2025 90 What is wrong with this model? Software Engineering 2024/2025 91 Typical test/exam exercises The following exercises are taken from previous tests and exams Software Engineering 2024/2025 92 Software Engineering 2024/2025 93 There is a deadlock preceding A. This is sooo 2004… Software Engineering 2024/2025 94 Which of these activity diagrams is incorrect, considering flow control? Software Engineering 2024/2025 95 Which of these activity diagrams is incorrect, considering flow control? Software Engineering 2024/2025 96 Software Engineering 2024/2025 97 Software Engineering 2024/2025 98 Which of the following sequences is possible during the execution of the activity diagram below? (assume the guards are there and correctly defined, where necessary) a. S->L->B->F->C->P b. S->L->B c. F->C->B->S->C->P d. S->C->P->F->C->B e. F->C->S->L->B Software Engineering 2024/2025 99 Which of the following sequences is possible during the execution of the activity diagram below? (assume the guards are there and correctly defined, where necessary) a. S->L->B->F->C->P b. S->L->B c. F->C->B->S->C->P d. S->C->P->F->C->B e. F->C->S->L->B Software Engineering 2024/2025 100 Which of the following statements is true? A. B. a. b. c. d. C. D. a. Diagrams C and D have the exact same semantics but are written in a different way. b. In all diagrams the student has to write an exam to finish the activity. c. C is incorrect as it deadlocks. d. In D the [yes]/[no] flows after the «decisionInput» are redundant. e. None of the other options is true. Software Engineering 2024/2025 101 Which of the following statements is true? A. B. a. b. c. d. C. D. a. Diagrams C and D have the exact same semantics but are written in a different way. b. In all diagrams the student has to write an exam to finish the activity. c. C is incorrect as it deadlocks. d. In D the [yes]/[no] flows after the «decisionInput» are redundant. e. None of the other options is true. Software Engineering 2024/2025 102 Which of the following sentences is true during the execution of the activity diagram below? a. The activity diagram does not work because it does not have an initial node. b. If just one of the two events is received either by the TerminateEvent accept event or a NewsEvent accept event, the flow leads to termination of the whole activity. c. If TerminateEvent is accepted by the TerminateEvent accept event action, it is required that the NewsEvent is received by the NewsEvent accept event activity so that the whole activity is able to end. d. If the TerminateEvent is accepted by the TerminateEvent accept event action, and this occurs after the activity flow has just passed by the action Display news, the whole activity ends. e. None of the other options is true. Software Engineering 2024/2025

Use Quizgecko on...
Browser
Browser