State Machine Diagrams (SMD)

  • Definition: SMD describes the behavior of a single class object. It identifies
    n What states the object can be in
    n What messages make the object change its state
    n Which objects require status checking
    n Which business rules determine valid status
  • Statea condition that occurs during the life of an object when it satisfies some criterion, performs an action or waits for an event
  • Conditions are semi-permanent” -- becuase it moves
  • A new state can be triggered by
    • External event
    • Internal change (data or time)
  • Transition: movement of an object from one state to another
  • When the object is in a different state, there is a business rule that is associated with this state change, and it is important to know what object is associated what business rule at what state.

SMD & OID

  • Each statechart details the object states in the sequence diagram. 

Naming Conventions

  • A simple condition -- e.g. "on" or "off"
  • Active names consisting of “…ing” or verb phrases -- e.g. "waiting" or "shipped"
  • Should not be nouns
  • Object may automatically perform an action when entering or leaving a state

Components

  • PseudostateStarting point noted by black dot
  • Destination StateState which an object moves after the completion of a transition
  • Origin StateOriginal state of an object from which the transition occurs
  • Transition Label (Message):

Transition-name (parameters, …) [guard-condition] / action expression

  • Guard Condition – qualifier or test on the transition, true/false condition that must be satisfied before the transition can fire
  • Action Expression – indicates some process that must occur before the transition is completed and the object arrives in the destination state
  • If either the transition-name or guard-condition is empty it evaluates to true

Example

  1. Starting with the "off" state
  2. On Button is pushed AND the bin is not empty AND safety cover is closed
  3. Run self-test()
  4. If the status returned is true, go to "on" state

How to make a SMD?

Concurrent state

i.e. More than one state at a time

Example

n Person object has marital status & citizen status

Internal state

  • Entry: action executed when entering the state

  • Do: action executed while in the state

  • Exit: action executed before leaving the state

Concurrent Path

  • Things that can happen in parallel. 
  • State Machine Diagram represents concurrent behavior with multiple paths called threads
  • There are 2 different graphical representations of conccurent paths

  • Upper: Swimlane
  • Lower: Synchronization Pseudostate, where vertical bars indicate where concurrent behavior begins or ends (called pseudostates)

Example

Class Exercise

  • Initially, the pone is turned off
    • When the phone is switched on
  • Plugged in and 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值