简体   繁体   English

这个序列的最佳 UML 图是什么?

[英]What is the best UML diagram for this sequence?

I am currently working on my final project at my school.我目前正在我的学校完成我的最后一个项目。 And am about to graduate.而且快毕业了。 I have always had difficulties with UML diagrams, and I am struggling to make my decision on which one I should use for picturing my code.我一直在使用 UML 图时遇到困难,而且我正在努力决定应该使用哪个图来描绘我的代码。

My code is a python script, and contains a loop that works in the following way:我的代码是一个 python 脚本,包含一个循环,其工作方式如下:

I run the script from a terminal -> 
   Terminal listens to two keys (W & Q).  
If Q is pressed the script stops. 
If W is pressed the loop begins in the following order:  
  Raspberry Pi camera takes a picture ->  
  Crop specific portion out of said picture and save it ->  
  Run Text recognition on that picture, which returns a text string and is saved in a variable ->  
  Run Regex to filter out junk characters from text string and create new "clean" text string ->  
  Run GET request to website using clean text string, and get return based on it. ->  
  Print out response from request.

Which diagram would be the best choice to make this sequence simple to understand.哪个图表是使这个序列易于理解的最佳选择。 I have looked into various diagrams such as System Sequence diagrams, and the like.我研究了各种图表,例如系统序列图等。 But I have yet to find anything that actually makes sense for me to use.但我还没有找到任何对我来说真正有意义的东西。 Should I just resort to using a flow chart?我应该求助于使用流程图吗? Or is there something out there that is better for me to use?或者有什么东西更适合我使用?

You want to use an Event-driven process chain (EPC).您想使用事件驱动的流程链 (EPC)。

In this case (without seeing your Code) I recommend using a 'Event-driven process chain' short: (EPC) , [German: (EPK), Ereignisgesteuerte Prozesskette] .在这种情况下(没有看到您的代码),我建议使用“事件驱动的流程链”短: (EPC) , [German: (EPK), Ereignisgesteuerte Prozesskette]

UMLs most of the time get used to display 'Class-Structures' rather than a process in a chain/script. UML 大部分时间习惯于显示“类结构”而不是链/脚本中的过程。

EPCs make use of logical operators, such as OR, AND, and XOR which can represent events like: EPC 使用逻辑运算符,例如 OR、AND 和 XOR,它们可以表示如下事件:

'Terminal listens to two keys (W & Q)' => XOR -> W ->Q '终端监听两个键(W & Q)' => XOR -> W ->Q

在此处输入图片说明

You can read more about it here .您可以在此处阅读更多相关信息。

edit:编辑:

In the case that you are limited to UML Diagrams only:如果您仅限于 UML 图表:

Out of the Seven Behavioral UML diagrams, you should indeed use the 'UML Activity diagram' as suggested by the user qwerty_so.在七个行为 UML 图中,您确实应该使用用户 qwerty_so 建议的“UML 活动图”。 It is similar to the EPC and can be described as the UML 'Flowchart' variant.它类似于 EPC,可以描述为 UML 的“流程图”变体。

UML Diagrams are limited to six 'Structural' UML diagrams and Seven ' Behavioral' UML diagrams : UML 图仅限于六个“结构”UML 图和七个“行为”UML 图

Behavioral UML diagrams行为 UML 图

  1. Activity diagram活动图
  2. Sequence diagram时序图
  3. Use case diagram用例图
  4. State diagram状态图
  5. Communication diagram通讯图
  6. Interaction overview diagram交互概览图
  7. Timing diagram时序图

You can read more about Activity diagrams here .您可以在此处阅读有关活动图的更多信息。

You can read more about the Types of UML Diagrams here .您可以在此处阅读有关 UML 图表类型的更多信息。

If you're in exam mode, here a quick overview.如果您处于考试模式,这里有一个快速概览。

UML offers two kind of diagrams : strutural diagrams that show how the system is made (classes, components, etc...), and behavioral diagrams that show what the the system does. UML 提供两种:显示系统如何构建的结构图(类、组件等),以及显示系统做什么的行为图。

Obviously you need a behavioural diagram.显然你需要一个行为图。 Use case show the user requirements, interaction diagrams show how system components interact, state diagram shows how the inner state evolves in relation with events, and activity diagram show the flow of controls and object.用例显示用户需求,交互图显示系统组件如何交互,状态图显示内部状态如何随事件演变,活动图显示控件和对象的流程。

Looking at your description, it seems that it's a flow of control.看你的描述,好像是控制流。 Your hesitation about flowchart tend to confirm this.你对流程图的犹豫往往证实了这一点。 So my advice: use an activity diagram .所以我的建议是:使用活动图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM