system analysis state machine diagrams
play

System Analysis State Machine Diagrams Jonathan Thaler Department - PowerPoint PPT Presentation

System Analysis State Machine Diagrams Jonathan Thaler Department of Computer Science 1 / 26 State Machine Diagrams Remember the Domain Model Definition... 2 / 26 Domain Modeling Domain Model A domain model provides a conceptual perspective


  1. System Analysis State Machine Diagrams Jonathan Thaler Department of Computer Science 1 / 26

  2. State Machine Diagrams Remember the Domain Model Definition... 2 / 26

  3. Domain Modeling Domain Model A domain model provides a conceptual perspective and may show: Domain objects or conceptual classes. Associations between conceptual classes. Attributes of conceptual classes. A domain model is a static representation of entities or classes modeling concepts of the domain and their static relationships . Domain Classes do not constitute software classes! However, they act as a source of inspiration for designing some software objects. 3 / 26

  4. State Machine Diagrams Definition State Machine Diagrams allow to model a dynamic view on life cycles of objects using states and transitions of individual, complex objects. In such diagrams the complete life cyle of a single object from its creation to its destruction becomes visible. 4 / 26

  5. State Machine Diagrams Definition State Machine Diagrams illustrates the interesting events and states of an object and the behaviour of an object in relation to an event. 5 / 26

  6. State Machine Diagrams Event An event is a significant or noteworthy occurrence. An event can be among others a message like a method call to an object; a time event or a timeout; a data condition. 6 / 26

  7. State Machine Diagrams State A state is the condition of an object at a moment in time, the time between events. It is specified through values of attributes at a given time; de- fined through combinations of values for which the object shows same behaviour. Therefore: for two different states, there is at least one event for which the object reacts different. 7 / 26

  8. State Machine Diagrams Transition A transition is a relationship between two states. When an event occurs, the object moves from the prior state to the subsequent state. Transitions have no duration and are atomic. The life cycle of an object is the sequence of states from the viewpoint of a single object from its creation to its destruction. 8 / 26

  9. State Machine Diagrams No need to illustrate every possible event. If an event arises that is not represented in the diagram, the event is ignored as far as the state machine diagram is concerned. If an object always responds the same way to an event, then it is considered state-independent with respect to that event. If, for all events of interest, an object always reacts the same way, it is a state-independent object. State-dependent objects react differently to events depending on their state. 9 / 26

  10. State Machine Diagrams Consider state machines for state-dependent objects with complex behaviour , not for state-independent objects. For example a telephone is very state-dependent, as the phone’s reaction to pushing a particular button depends on the current state. It is for these kind of state-dependent problems that a state machine diagram may add value to their understanding or document something. Therefore, state machine diagrams can be helpful for understanding critical parts of a domain, system or object which have non-trivial complex states and transitions. 10 / 26

  11. State Machine Diagrams State machines are applied in two ways: 1. To model the behaviour of a complex reactive object in response to events. For example phones, cars, microwave ovens, transactions, business objects, role mutators (for example a person changing roles from being a civilian to a veteran). 2. To model allowed sequences of operations in a protocol or language specification. For example communication protocols such as TCP, window flow or navigation, user interface controllers or sessions, use case operations. 11 / 26

  12. State Machine Diagrams Transition Actions and Guards 12 / 26

  13. Transition Actions and Guards Transitions A transition can cause an action to fire. A transition may also have a conditional guard (a boolean test). The transition only occurs if the test passes . Figure: Transition action and guard notation. 13 / 26

  14. State Machine Diagrams Superstate and Substates 14 / 26

  15. Superstate and Substates Nesting A state allows to contain substates by nesting. A substate inherits the transitions of its superstate (the enclosing state). 15 / 26

  16. Superstate and Substates Nesting In super states at any time only one nested state must be active 16 / 26

  17. State Machine Diagrams Orthogonal States 17 / 26

  18. Orthogonal States Definition States can be broken into several orthogonal state diagrams that run concur- rently . 18 / 26

  19. Orthogonal States Definition Orthogonal concurrently running states can also have a history pseudostate . 19 / 26

  20. State Machine Diagrams Internal Activities 20 / 26

  21. Internal Activities Definition States can react to events without transition, using internal activities which put the event, guard and activity inside the state box itself. An internal activity is similar to a self-transition , which loops back to the same state. Figure: Internal events shown with the typing state of a text field. 21 / 26

  22. Internal Activities Definition There exist two special entry and exit activities: 1. Entry activity is executed whenever the state is entered. 2. Exit activity is executed whenever the state is left. Internal activities do not trigger the entry and exit activities (that is the difference between internal activities and self-transitions). Figure: Internal events shown with the typing state of a text field. 22 / 26

  23. State Machine Diagrams Activity States 23 / 26

  24. Activity States Definition Activity Diagrams allow to express activies, that is states which can be interrupted and have a duration through activity states . The ongoing activity is marked with the do/ : Both do-activities and regular activities represent carrying out some behaviour. Regular activities occur instantaneously and cannot be interrupted by regular events. do-activities can take finite time and can be interrupted . 24 / 26

  25. State Machine Diagrams Modeling 25 / 26

  26. Modeling 1. Create an initial model by modeling a first, initial life cycle with a simple understanding of the domain. 2. Focus on when the object is created , when it is destroyed and which intermediary states it has. 3. Define external system events , which regard the object. 4. Find message events to this object , originating from other objects and its reaction to it: messages to other objects, to actors, error messages). 5. Find states in which the object reacts different to same events. 6. Find events which cause the object to transition in the states in point 5. 7. Connect the transitions and events. 8. Assign actions to the events: internal / external messages or important computations. 26 / 26

Recommend


More recommend