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

What would be the better unit to draw state machine diagrams in SRS?

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

状态图中清楚地显示了对象的固有状态。但是,我的问题是我们如何找到我们应该绘制的状态。是来自组件还是 类?

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

在 UML 中,状态机是为 classifier 定义的。他们可以定义事件驱动的行为(behavioral state-machine) or the valid set of interactions with the classifier (protocol state-machine). A classifier 通常是一个 class 或一个组件:两者都是可能的。

但在您的 SRS 中您并不关心:您不需要为每个 class 或每个组件提供 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.

您肯定会使用 classes 对 1 进行建模,并且关于 shopping cart 上操作有效性的约束很容易在状态机中表达。顺便说一句,对于任何具有要跟踪的生命周期的对象来说,这是典型的。其他 classes 似乎没有任何有趣的状态可以建模。

您肯定会使用 controller 组件对 2 进行建模,并且事件驱动的行为集可以使用状态机轻松清晰地表达。

所以最终,您不关心它是 class 还是组件。唯一应该在 SRS 中驱动您的建模的是,是否存在 可以表达更多 precisely/easily/clearly 的行为或约束一个状态机。许多 SRS 甚至不显示任何状态机,因为状态只出现在解决方案的设计中。