State Diagrams PB007 Software Engineering I Bruno Rossi 7. 11. 2016 Software Engineering I (PB007) State Diagrams 7. 11. 2016 1 / 13 State Diagrams The State Diagram models the dynamic behavior (life cycle) of one reactive object (class, use case, system, subsystem). Its essential components are: States Transitions Events Software Engineering I (PB007) State Diagrams 7. 11. 2016 2 / 13 The components of a state diagram Software Engineering I (PB007) State Diagrams 7. 11. 2016 3 / 13 State The State represents a semantically important situation in which the object can be. It is generally determined by the value of attributes, relations with other objects, and activities performed. Conditions may include: Entry/Exit actions Internal transitions/actions Internal activities Software Engineering I (PB007) State Diagrams 7. 11. 2016 4 / 13 Transitions Transitions define how you will get from one state to another. The transition elements: Events Conditions Actions Syntax: event[guard condition]/action Semantics: At the occurence of the event, and with condition satisfied, perform action and go to the new state. Software Engineering I (PB007) State Diagrams 7. 11. 2016 5 / 13 Events Events are the stimulus to which the subject may react by changing the status or performing some kind of operation. . We distinguish 4 types of events: Call event - calling the operations of an object. Signal event - asynchronous emission and reception of signals from one object to another. Change event - truth expression. The event occurs after you change its value from false to true. Time event - events occur at a certain time (when()) or after a certain time (after()) Software Engineering I (PB007) State Diagrams 7. 11. 2016 6 / 13 Events - examples Software Engineering I (PB007) State Diagrams 7. 11. 2016 7 / 13 Composite state Composite states are states that have some nested conditions. We distinguish two types of composite states: Simple composite states - that are just in one area - they are suitable to capture the inheritance aspects between different states. Orthogonal composite states - that cover two or more areas. Each of them contains a nested state diagram. Their execution is carried out in parallel. Software Engineering I (PB007) State Diagrams 7. 11. 2016 8 / 13 Composite state - Example Software Engineering I (PB007) State Diagrams 7. 11. 2016 9 / 13 Composite state - Example II Software Engineering I (PB007) State Diagrams 7. 11. 2016 10 / 13 Additional Resources http://www.uml-diagrams.org/state-machine-diagrams.html http://mpavus.wz.cz/uml/uml-b-state-3-2-2.php http://www.agilemodeling.com/artifacts/ stateMachineDiagram.htm http://www.sparxsystems.com.au/resources/uml2_tutorial/ uml2_statediagram.html Software Engineering I (PB007) State Diagrams 7. 11. 2016 11 / 13 Tasks Select one reactive object in your system that you will model with a state diagram. First, draw up a list of all the states that can be found in the object. Select then those that are really interesting to discriminate with respect to the features of the system. Create a list of events (external stimuli) that cause interaction with the object. From the list, select those that affect/alter the state of the object. On the basis of the lists of conditions and events, draw the state diagram. Try to take advantage of inheritance between states and thus simplifying the resulting model. Upload the PDF report into the folder for (Week 07). Deadline: Friday, 11.11.16 23:59 Software Engineering I (PB007) State Diagrams 7. 11. 2016 12 / 13 Customization of PDF Export Software Engineering I (PB007) State Diagrams 7. 11. 2016 13 / 13