【翻译】What is State Machine Diagram(什么是状态机图)?

本文翻译自《What is State Machine Diagram》,介绍了状态机图的概念和基本构成,包括状态、事件、转移、动作等,并阐述了状态机图在描述对象行为上的重要性,特别是在系统行为依赖状态变化的场景下。同时,文中通过银行账户取款为例,解释了状态变化如何影响行为,并提到了状态机图与序列图的区别。最后,文章讨论了子状态、历史状态和并发状态等复杂概念,展示了状态机图在简化和分析系统动态行为上的作用。" 44645827,4970375,C语言结构体与预编译详解,"['C语言', '数据结构', '编程基础']
摘要由CSDN通过智能技术生成

【翻译】What is State Machine Diagram(什么是状态机图)?

写在前面

在上一篇学习类图的时候将这个网站上的类图的一篇文章翻译了出来,感觉受益良多,今天来学习UML状态机图,在网站找了很多的博客,但是都有些雷同的现象,所以又计划从该网站上学习UML状态机图,翻译出来以供大家参考。下面是原文链接:
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-state-machine-diagram/

正文

The behavior of an entity is not only a direct consequence of its inputs, but it also depends on its preceding state. The past history of an entity can best be modeled by a finite state machine diagram or traditionally called automata. UML State Machine Diagrams (or sometimes referred to as state diagram, state machine or state chart) show the different states of an entity. State machine diagrams can also show how an entity responds to various events by changing from one state to another. State machine diagram is a UML diagram used to model the dynamic nature of a system.

一个实体的行为不仅是其输入的直接的结果,而且还取决于其之间的状态。一个实体的过去的历史能够通过有限状态机图或者传统上被称为自动机(automata(不知道是个什么东东,还望大佬解惑。))的图来建模。UML状态机图(UML State Machine Diagram)(有时被称为 状态图(state diagram), 状态机(stae machine) 或 状态图(state chart))展示了一个实体的不同的状态。状态机图同样也可以展示一个实体如何通过从一个状态到另一个状态的改变来相应各种各样的事件。

01-uml-state-machine-diagram-in-uml-hierarchy

Why State Machine Diagrams(为什么是状态机图)?

State machine diagram typically are used to describe state-dependent behavior for an object. An object responds differently to the same event depending on what state it is in. State machine diagrams are usually applied to objects but can be applied to any element that has behavior to other entities such as: actors, use cases, methods, subsystems systems and etc. and they are typically used in conjunction with interaction diagrams (usually sequence diagrams).

状态机图经常地用来描述一个对象的状态依赖行为。 一个对象会依据其当前所处的状态来以不同的方式响应同样的事件。状态机图通常被应用于对象,但是也可以被应用于对其他实体有行为的任何元素比如: 参与者(actors)、 用例(use case)、 方法(methods)、 (子系统(subsystems systems))等。他们经常与交互图被结合使用(通常是时序图(sequence diagram))。

For example:
举例来说:

Consider you have $100,000 in a bank account. The behavior of the withdraw function would be: balance := balance - withdrawAmount: ; provided that the balance after the withdrawal is not less than $0; this is true regardless of how many times you have withdrawn money from the bank. In such situations, the withdrawals do not affect the abstraction of the attribute values, and hence the gross behavior of the object remains unchanged.

假设你的银行账户上有 $100,000刀。 withdraw(取钱)函数的行为将是: balance := balance - withdrawAmount; 假设 取钱之后的余额不小于 $0 ; 不管你从银行取了多少钱,这都是真的。 在这种情况下,取钱行为不会影响到属性值的抽象,因此该对象的整体行为保持不变。

However, if the account balance would become negative after a withdrawal, the behavior of the withdraw function would be quite different. This is because the state of the bank account is changed from positive to negative; in technical jargon, a transition from the positive state to the negative state is fired.

不管怎样,如果 账户余额在取钱之后变为了负数,withdraw(取钱)函数的行为将会变为十分不同。这是因为银行账户的状态从积极状态(positive)改变为了消极状态(negative); 用专业术语来表示就是,一个从积极状态到消

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值