www.wileyeurope .com/college/van lamsweerde Chap.13: Modeling System Behaviours © 2009 John Wiley and Sons Building System Models for RE Building System Models for RE Chapter 13 Modeling System Behaviours www.wileyeurope .com/college/van lamsweerde Chap.13: Modeling System Behaviours © 2009 John Wiley and Sons 2 Building models for RE Behaviors - Behaviors - Scenarios Scenarios (Chap.13) Behaviors - Behaviors - State machines State machines (Chap.13) www.wileyeurope .com/college/van lamsweerde Chap.13: Modeling System Behaviours © 2009 John Wiley and Sons 3 The behaviour model Behaviour view of the system being modeled – Modelling the dynamic of an agent, consider: Modelling the dynamic of an agent, consider: Specific behaviours of specific agent instances All possible behaviours of any agent instance. Specific instance behaviours are captured through scenarios. General class behaviours are captured through state machines. www.wileyeurope .com/college/van lamsweerde Chap.13: Modeling System Behaviours © 2009 John Wiley and Sons 4 Modeling system behaviours: outline Modeling instance behaviours – Scenarios as UML sequence diagrams – Scenario refinement Modeling class behaviours – State machines as UML state diagrams – State machine refinement Building behaviour models www.wileyeurope .com/college/van lamsweerde Chap.13: Modeling System Behaviours © 2009 John Wiley and Sons 5 Modeling instance behaviours What is scenario? What is scenario? – Is a temporal sequence of interaction events among agent instances – Positive scenario: Positive scenario: the sequence of interactions illustrates a possible way of satisfying an behavioural goal. – Negative scenario: Negative scenario: the sequence of interactions illustrates a possible way of satisfying an obstacle to a goal. Interaction Interaction: – Is an instantaneous object – Corresponding to the source agent instance applying an operation whose effect is monitored by the target agent instance. – Source agent controls the interaction; target agent monitors it. www.wileyeurope .com/college/van lamsweerde Chap.13: Modeling System Behaviours © 2009 John Wiley and Sons 6 Scenario as UML sequence diagrams Sequence diagrams are a UML variant of the event trace diag. Basic UML syntax for sequence diagrams is similar to the one used in event trace diagrams. Figure 13.1 – Scenario represented by a sequence diagram : Train Actuator/Sensor : OnBoard Controller doorsOpening exit doorsClosing p1: Passenger entrance p2: Passenger software agent instance environment agent time interaction event name ! trainStopped startAcceler www.wileyeurope .com/college/van lamsweerde Chap.13: Modeling System Behaviours © 2009 John Wiley and Sons 7 Scenario as UML sequence diagrams (2) Figure 13.2 – Sequence diagram for a loan scenario : LoanManager BookRequest (PatrID, BookID) : Staff self-interaction event attributes instance disappears : CopyManager LoanQtyOK? (PatrID) CpyAvailable? (BookID) Reserved? (BookID) OK-Available (CopyID) OK-Book (PatrID, CopyID) checkOut (PatrID, CopyID) Registered? (PatrID) Figure 13.3 – Negative scenarios and optional interactions opt : Train Actuator/Sensor : OnBoard Controller AlarmPressing AccelerComnd doorsOpening prohibited interaction neg : Train Actuator/Sensor doorsOpening exit doorsClosing :Passenger optional interaction : Passenger : OnBoard Controller ! trainStopped startAcceler AlarmPropagation www.wileyeurope .com/college/van lamsweerde Chap.13: Modeling System Behaviours © 2009 John Wiley and Sons 8 Scenario refinement: Episodes and agent decomposition When elaborating complex scenarios stepwise, expressing a When elaborating complex scenarios stepwise, expressing a coarse-grained scenario first then refine it with further details coarse-grained scenario first then refine it with further details coarse-grained scenario -> finer-grained scenario: coarse-grained scenario -> finer-grained scenario: – Introducing episodes Introducing episodes – Decomposing an agent instance into finer-grained agents. Decomposing an agent instance into finer-grained agents. www.wileyeurope .com/college/van lamsweerde Chap.13: Modeling System Behaviours © 2009 John Wiley and Sons 9 Scenario refinement: Episodes Figure 13.4 – Scenario refinement: introducing episodes :Scheduler meetingRequest (dateRange, withWhom) : Initiator reference to another diagram : Participant schedule Determination ConstraintsAcquired notification (date, location) notification (date, location) :Scheduler ? constraints (dateRange) : Participant OK-constr ! constraints sd ConstraintsAcquired episode OK-request www.wileyeurope .com/college/van lamsweerde Chap.13: Modeling System Behaviours © 2009 John Wiley and Sons 10 Scenario refinement: agent decomposition Figure 13.5 – Scenario refinement: agent decomposition : LibraryManager BookRequest (PatrID, BookID) : Staff RequestOK? (PatrID, BookID) OK-Book (PatrID, CopyID) : LoanManager : Staff : CopyManager CpyAvailable? (BookID) Reserved? (BookID) OK-Available (CopyID) checkOut (PatrID,CopyID) BookRequest (PatrID, BookID) OK-Book (PatrIDCopyID) LoanQtyOK? (PatrID) Registered? (PatrID) [...]... lamsweerde Chap .13: Modeling System Behaviours © 2009 John Wiley and Sons 19 Modeling system behaviours: outline Modeling instance behaviours – Scenarios as UML sequence diagrams – Scenario refinement Modeling class behaviours – State machines as UML state diagrams – State machine refinement Building behaviour models www.wileyeurope com/college/van lamsweerde Chap .13: Modeling System Behaviours ©.. .Modeling system behaviours: outline Modeling instance behaviours – Scenarios as UML sequence diagrams – Scenario refinement Modeling class behaviours – State machines as UML state diagrams – State machine refinement Building behaviour models www.wileyeurope com/college/van lamsweerde Chap .13: Modeling System Behaviours © 2009 John Wiley and Sons 11 Modeling class behaviours State... provide visual abstractions of explicit behaviours of any agent instance in a class Expecting goals, scenarios and state machines to form a win-win partnership for building complex models Table 13.1 summarizes the respective pros/cons of goals, scenarios and state machines (textbook.p464) www.wileyeurope com/college/van lamsweerde Chap .13: Modeling System Behaviours © 2009 John Wiley and Sons 21... diagram to a ‘consuming’ diagram where this event causes transitions – This allows for synchronization among multiple diagrams Entry/exit actions www.wileyeurope com/college/van lamsweerde Chap .13: Modeling System Behaviours © 2009 John Wiley and Sons 14 State machines as UML state diagrams (3) copyBorrowing [ LastCopy ] copyReturn Borrowable guard UnBorrowable copyReturn copyBorrowing [not LastCopy ]... AtPlatform] / Display terminalInfo doorsClosed doorsOpen doorsClosing / Activate warningRinging Figure 13.8 – Auxiliary actions in a state diagram www.wileyeurope com/college/van lamsweerde Chap .13: Modeling System Behaviours © 2009 John Wiley and Sons 15 State machines as UML state diagrams (4) event notification to consumer checkOut (PatrID, self) / send BookInfo.copyBorrowing Available onLoan loss return... Inform initiator [all available] [conflicts] Planning … Resolving Figure 13.10 – Avoiding duplicated actions: entry and exit actions within a state www.wileyeurope com/college/van lamsweerde Chap .13: Modeling System Behaviours © 2009 John Wiley and Sons 16 State machine refinement: sequential and concurrent sub-states … when we elaborate a complex state machine model stepwise: – specify first a coarse-grained... decomposition – An SM state may be decomposed into concurrent sub-states – Composite state can be structured as a parallel composition of nested diagrams www.wileyeurope com/college/van lamsweerde Chap .13: Modeling System Behaviours © 2009 John Wiley and Sons 17 State machine refinement: sequential decomposition startAcceler [Acceler > 0] Stopped (a) startAcceler [Acceler > 0] Moving include / movingSubstates... for the TrainInfo entity controlled by TrainController Semantic rules define sequential state decomposition more precisely: [textbook, p459) www.wileyeurope com/college/van lamsweerde Chap .13: Modeling System Behaviours © 2009 John Wiley and Sons 18 State machine refinement: parallel decomposition TrainInfoState MovementState state name composite state startAcceler [doorsState = closed] AccelerComnd... agent associated with the State Machine does not controls – Internal events: events controlled by the agent associated with the State Machine www.wileyeurope com/college/van lamsweerde Chap .13: Modeling System Behaviours © 2009 John Wiley and Sons 12 State machines as UML state diagrams A state machine is represented in UML by a variant of a statechart called a state diagram Some features … – State... attribute onLoan return (PatrID, self) loss final state Figure 13.6 – A simple SM diagram for a BookCopyInfo entity controlled by LibraryManager www.wileyeurope com/college/van lamsweerde Chap .13: Modeling System Behaviours © 2009 John Wiley and Sons 13 State machines as UML state diagrams (2) Guarded transitions – A guard captures a necessary condition for transition firing Actions – An action is . Chap .13: Modeling System Behaviours © 2009 John Wiley and Sons 4 Modeling system behaviours: outline Modeling instance behaviours – Scenarios as UML sequence diagrams – Scenario refinement Modeling. Chap .13: Modeling System Behaviours © 2009 John Wiley and Sons 11 Modeling system behaviours: outline Modeling instance behaviours – Scenarios as UML sequence diagrams – Scenario refinement Modeling. Chap .13: Modeling System Behaviours © 2009 John Wiley and Sons 20 Modeling system behaviours: outline Modeling instance behaviours – Scenarios as UML sequence diagrams – Scenario refinement Modeling