uml - 在 SRS 中绘制状态机图的更好单位是什么?

标签 uml state-machine requirements state-diagram system-analysis

最近我正在为我的大学项目编写 SRS 文档。当我绘制状态机图时,我很困惑应该绘制哪些部分。是为了组件吗?还是为了类(class)?

状态图中清楚地显示了对象的固有状态。但是,我的问题是我们如何找到我们应该绘制的状态。这是从组件或类中获取的吗?

最佳答案

SRS 是 System Requirement Specification :您记录了需求,而不是解决方案。因此,SRS 中的状态图应该与需求相关,无论它们是什么。

在 UML 中,状态机是为分类器定义的。他们可以定义事件驱动的行为 ( behavioral state-machine ) 或与分类器的有效交互集 ( protocol state-machine )。一个classifier通常是一个类或一个组件:两者都是可能的。

但在你的 SRS 中你并不关心:你不需要为每个类或每个组件提供 SM;仅当有州相关要求时才需要提供 SM。

虚拟示例:

  1. The user may create a shopping basket, and add items from the catalog to the cart. Items may also be removed. The user may view the shopping cart and continue the purchases. The user can check-out the shopping cart, and once the payment is completed, no changes shall be possible anymore to the cart.
  2. The controller ignites the rocket booster. Once the booster fuel level is detected to be empty, the controller activate the decoupling of the booster, and ignites the main engine. Once the booster is succesfully decoupled, the controller shall monitor any variation in altitude.

您当然会使用类对 1 进行建模,并且关于购物车操作有效性的约束可以轻松地在状态机中表达。顺便说一句,这对于任何具有要跟踪的生命周期的对象来说都是典型的。其他类似乎没有任何有趣的状态可供建模。

您当然会使用 Controller 组件来构建模型 2,并且事件驱动的行为集可以通过状态机轻松、清晰地表达。

所以最终,您并不关心它是一个类还是一个组件。唯一应该插入 SRS 中建模的事情是,是否存在可以使用状态机更精确/轻松/清晰地表达的行为或约束。。许多 SRS 甚至不显示任何状态机,因为状态仅在解决方案的设计中出现。

关于uml - 在 SRS 中绘制状态机图的更好单位是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62988451/

相关文章:

java - 具有子状态的 Spring 状态机生成器抛出错误 - "Initial state not set"

requirements - SRS 和需求分析有什么区别?

java - 为什么 UML 显示 Android Adapter 接口(interface)有一个 View 和一个 ViewGroup

python - 我的 Python 状态机陷入无限循环

java - 生成 hibernate 实体的 ERD Eclipse 插件

asp.net - ASP.Net Web 应用程序的工作流程设计建议?

controller - Silverstripe - 对另一个 Controller 的要求

compilation - 在另一台 Windows 机器上运行 Rust 编译程序有什么要求?

mysql - 如何使复合键唯一?

android - 如何在 UML 图中建模 Firebase 数据库?