1
votes

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?

2
Take an Activity Diagram. That's best suited for your purpose. - qwerty_so
Appriciate the comment qwerty. This is what i ended up doing. - Tejsfrank

2 Answers

2
votes

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.

1
votes

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.

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.