Search code examples
umlmodelingdiagramcontrol-flow

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.

My code is a python script, and contains a loop that works in the following way:

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?


Solution

  • You want to use an Event-driven process chain (EPC).

    In this case (without seeing your Code) I recommend using a 'Event-driven process chain' short: (EPC), [German: (EPK), Ereignisgesteuerte Prozesskette].

    UMLs most of the time get used to display 'Class-Structures' rather than a process in a chain/script.

    EPCs make use of logical operators, such as OR, AND, and XOR which can represent events like:

    'Terminal listens to two keys (W & Q)' => XOR -> W ->Q

    enter image description here

    You can read more about it here.

    edit:

    In the case that you are limited to UML Diagrams only:

    Out of the Seven Behavioral UML diagrams, you should indeed use the 'UML Activity diagram' as suggested by the user qwerty_so. It is similar to the EPC and can be described as the UML 'Flowchart' variant.

    UML Diagrams are limited to six 'Structural' UML diagrams and Seven 'Behavioral' UML diagrams:

    Behavioral UML diagrams

    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.