UML State Machines

UML State Machines

Formal Specification of Software UML State Machines Bernhard Beckert UNIVERSITÄT KOBLENZ-LANDAU B. Beckert: Formal Formal Specification of Software { p.1 UML State Machines Important type of UML diagrams For modelling behaviour Lifecycle of objects Behaviour of operations History Invented by D. Harel (State Charts) Made popular by J. Rumbaugh (OMT) B. Beckert: Formal Formal Specification of Software { p.2 Notions Related to State Machines State Transition Event Action, Activity Guards Sending messages Nesting Concurrency History states B. Beckert: Formal Formal Specification of Software { p.3 The game can end both when it is White's and when it is Black's turn. The moving player can end the game: winning (checkmate), loosing (resign), or with a draw. Example: Chess A chess game consists of alternate moves of Black and White. White moves first. B. Beckert: Formal Formal Specification of Software { p.4 The game can end both when it is White's and when it is Black's turn. The moving player can end the game: winning (checkmate), loosing (resign), or with a draw. Example: Chess A chess game consists of alternate moves of Black and White. White StateMachine Behaviour of ChessGame moves first. Event White's Move Initial State bm(p:Piece) Transition Black's Move State B. Beckert: Formal Formal Specification of Software { p.4 The moving player can end the game: winning (checkmate), loosing (resign), or with a draw. Example: Chess A chess game consists of alternate moves of Black and White. White StateMachine Behaviour of ChessGame moves first. The game can end both Event when it is White's and White's Move when it is Black's turn. Initial State bm(p:Piece) Transition Black's Move State B. Beckert: Formal Formal Specification of Software { p.4 The moving player can end the game: winning (checkmate), loosing (resign), or with a draw. Example: Chess A chess game consists of alternate moves of Black and White. White Behaviour of ChessGame moves first. The game can end both when it is White's and White's Move when it is Black's turn. bm(p:Piece) Final State Black's Move B. Beckert: Formal Formal Specification of Software { p.4 loosing (resign), or with a draw. Example: Chess A chess game consists of alternate moves of Black and White. White Behaviour of ChessGame moves first. The game can end both when it is White's and White's Move when it is Black's turn. bm(p:Piece) Final State The moving player can Black's Move end the game: winning (checkmate), B. Beckert: Formal Formal Specification of Software { p.4 loosing (resign), or with a draw. Example: Chess A chess game consists of alternate moves of Black and White. White Behaviour of ChessGame moves first. The game can end both when it is White's and White's Move White Win when it is Black's turn. bm(p:Piece) The moving player can Black's Move Black Win end the game: winning (checkmate), B. Beckert: Formal Formal Specification of Software { p.4 or with a draw. Example: Chess A chess game consists of alternate moves of Black and White. White Behaviour of ChessGame moves first. The game can end both when it is White's and White's Move White Win when it is Black's turn. bm(p:Piece) The moving player can Black's Move Black Win end the game: winning (checkmate), loosing (resign), B. Beckert: Formal Formal Specification of Software { p.4 or with a draw. Example: Chess A chess game consists of alternate moves of Black and White. White Behaviour of ChessGame moves first. The game can end both when it is White's and White's Move White Win when it is Black's turn. bm(p:Piece) The moving player can Black's Move Black Win end the game: winning (checkmate), loosing (resign), B. Beckert: Formal Formal Specification of Software { p.4 Example: Chess A chess game consists of alternate moves of Black and White. White Behaviour of ChessGame moves first. The game can end both when it is White's and White's Move White Win when it is Black's turn. bm(p:Piece) The moving player can Black's Move Black Win end the game: winning (checkmate), loosing (resign), or with a draw. B. Beckert: Formal Formal Specification of Software { p.4 Example: Chess A chess game consists of alternate moves of Black and White. White Behaviour of ChessGame moves first. The game can end both when it is White's and White's Move White Win when it is Black's turn. Draw bm(p:Piece) The moving player can Black's Move Black Win end the game: winning (checkmate), loosing (resign), or with a draw. B. Beckert: Formal Formal Specification of Software { p.4 States Nodes of the graph Labelled with: name, do-, entry-, exit-action, . Initial and final states have special shapes Transitions Edges of the graph Labelled with: event, guard, action, . State Machines State Machine Labelled, finite graph (cycles possible) B. Beckert: Formal Formal Specification of Software { p.5 Transitions Edges of the graph Labelled with: event, guard, action, . State Machines State Machine Labelled, finite graph (cycles possible) States Nodes of the graph Labelled with: name, do-, entry-, exit-action, . Initial and final states have special shapes B. Beckert: Formal Formal Specification of Software { p.5 State Machines State Machine Labelled, finite graph (cycles possible) States Nodes of the graph Labelled with: name, do-, entry-, exit-action, . Initial and final states have special shapes Transitions Edges of the graph Labelled with: event, guard, action, . B. Beckert: Formal Formal Specification of Software { p.5 Do NOT use State Machines . when several objects are involved (interaction diagrams are better) When to Use State Machines Use State Machines . at an early stage of software development when behaviour of an object (lifecycle) or operation is not well understood yet B. Beckert: Formal Formal Specification of Software { p.6 When to Use State Machines Use State Machines . at an early stage of software development when behaviour of an object (lifecycle) or operation is not well understood yet Do NOT use State Machines . when several objects are involved (interaction diagrams are better) B. Beckert: Formal Formal Specification of Software { p.6 Implementation view certain attributes have certain values State Abstract view the same response to the same stimuli the same active behaviour B. Beckert: Formal Formal Specification of Software { p.7 State Abstract view the same response to the same stimuli the same active behaviour Implementation view certain attributes have certain values B. Beckert: Formal Formal Specification of Software { p.7 Role in diagram triggers a transition is “consumed” when transition is executed can be saved under certain circumstances Event Properties observable in the environment of the current object takes place at certain point in time (has no duration) has possibly parameters B. Beckert: Formal Formal Specification of Software { p.8 Event Properties observable in the environment of the current object takes place at certain point in time (has no duration) has possibly parameters Role in diagram triggers a transition is “consumed” when transition is executed can be saved under certain circumstances B. Beckert: Formal Formal Specification of Software { p.8 Types of Events Signal event An object that is dispatched (thrown) and received (caught) Call event Represents the dispatch of an operation Time event Represents the passage of a certain amount of time Change event Represents the fact that a Boolean expression is changed to true The expression is checked continuously (polling) B. Beckert: Formal Formal Specification of Software { p.9 Role in diagram triggering controlled by events, guards, state exit conditions execution can cause actions Transition Properties decribes change from one state to another state without duration when executed B. Beckert: Formal Formal Specification of Software { p.10 Transition Properties decribes change from one state to another state without duration when executed Role in diagram triggering controlled by events, guards, state exit conditions execution can cause actions B. Beckert: Formal Formal Specification of Software { p.10 Authentication is done by checking a PIN. The PIN can be correct or not. Unseccessful attempts are counted, If the counter exceeds a limit, the customer is rejected. Example: ATM The customer must pass authentication before withdrawing money. B. Beckert: Formal Formal Specification of Software { p.11 Authentication is done by checking a PIN. The PIN can be correct or not. Unseccessful attempts are counted, If the counter exceeds a limit, the customer is rejected. Example: ATM The customer must pass authentication before Customer at ATM withdrawing money. Authentication WithdrawMoney B. Beckert: Formal Formal Specification of Software { p.11 The PIN can be correct or not. Unseccessful attempts are counted, If the counter exceeds a limit, the customer is rejected. Example: ATM The customer must pass authentication before Customer at ATM withdrawing money. Authentication is done by Authentication WithdrawMoney checking a PIN. B. Beckert: Formal Formal Specification of Software { p.11 The PIN can be correct or not. Unseccessful attempts are counted, If the counter exceeds a limit, the customer is rejected. Example: ATM The customer must pass authentication before Customer at ATM withdrawing money. Authentication is done by Authentication CheckPIN WithdrawMoney checking a PIN. B. Beckert: Formal Formal Specification of Software { p.11 Unseccessful attempts are counted, If the counter exceeds a limit, the customer is rejected. Example: ATM The customer must pass authentication before Customer at ATM withdrawing money. Authentication is done by Authentication CheckPIN WithdrawMoney checking a PIN. The PIN can be correct or not. B. Beckert: Formal Formal Specification of Software { p.11 Unseccessful attempts are counted, If the counter exceeds a limit, the customer is rejected.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    99 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us