绘制 UML 状态图
When drawing state diagrams, how do you know which states get put in boxes and which states are for the transition arrows? I noticed that transitions are states too.
I'm looking at figure 1 on this page:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
转换不是状态。转换是将对象从一种状态移动到下一种状态的事件。状态由对象中的变量值和对象的行为定义。以具有“新等待批准”值的 Student 对象为例。该学生不得注册或上课。但如果值更改为“已批准”,则可能会允许同一学生注册并上课。有什么区别?学生对象实际上有两种状态。
是什么导致 Student 对象从一种状态转移到另一种状态?也许是“批准到来”事件。因此,“批准到达”沿着两个州之间的箭头移动。
Transitions are NOT states. Transitions are the events that move an object from one state to the next. States are defined by the value of variables in the object and by the behaviour of the object. Take for instance a Student object that has a value "new-waiting for approval" value. That student is not allowed to register for or attend classes. But the same student may be allowed to register for and attend classes if the value changes to "approved". What's the difference? The student object actually has two states.
What causes the Student object to move from one state to the next? The event "Approval Arrives" maybe. So Approval Arrives go on the arrow between two states.
图中的“转换箭头”不是状态,它们是“转换/动作/发生”。例如,在上述图中,“已计划”是状态,“开放”是进入“开放注册”状态后的操作。这种“打开”转换可以用“正在打开”来替换更详细的内容
不幸的是,像计划/打开这样的转换操作也很容易与状态混淆,但这不是意图。
'Transition arrows' in the diagram are not states, they are "TRANSITION/ACTION/HAPPENING". For e.g. in the mentioned figure, "Scheduled" is the state, open is action after which it goes to "Open for enrollment" state. This "open" transition can be replaced more verbose with "is being opened"
Unfortunately, the transition actions like scheduled/open are very easily confused for a state as well, but that is not the intent.
首先,您需要识别系统中的对象。在这些对象中,您需要选择随时间变化的概率的对象。然后您需要分别为所有这些选定的对象绘制状态图。方框代表该对象的状态,箭头代表导致状态改变的活动的特定对象。
At first you need to identify objects in your system. Among those objects, You need to select objects which have probability of change over the time.Then You need to draw state diagrams for all those selected objects separately.Boxes represent the states of that object and arrow represents the activity which causes to change the state of particular object.
我同意一点,在规范中,在某些示例中,转换看起来像状态。
对我来说“selectAmount”并不完全是一个州名......
I agree of one point, in specification , on some example, transitions looks like state.
For me "selectAmount" is not exactly a state name ...