Simplifying Complex Processes visualisation with PlantUML

Written in

by

A modern espresso maker with steam and coffee beans on a kitchen counter, evoking a warm, inviting aroma, with a diagram created wit PUML

As a Creative Technologist & AI Specialist, I often find myself needing to visualise complex processes and workflows. While there are many tools available for creating diagrams, one stands out for its simplicity and power: PlantUML. It allows you to define diagrams using a concise and readable text-based language, which is also particularly useful for version control and collaboration.

Quick Guide to PlantUML

PlantUML is a tool for creating UML diagrams from a simple text description, making it ideal for developers, project managers, and technical writers. It supports various diagram types like sequence, class, and activity diagrams, among others. What sets PlantUML apart is its compatibility with version control systems. Diagrams coded in plain text can be versioned and shared with ease, facilitating collaborative work and documentation maintenance.

Integrating seamlessly with many IDEs and documentation systems, PlantUML streamlines the process of visualising complex ideas and workflows. This compatibility enhances team collaboration and keeps diagrams closely tied to project development. PlantUML stands out for its efficiency in creating and updating diagrams, offering a maintainable and collaborative approach to software documentation and design visualisation.

Moka Morning: Brewing Diagrams with PlantUML

Starting the day with a good coffee is a universal routine, and in Italy, it’s typically with a Moka pot. This cherished daily ritual serves as our inspiration for demonstrating PlantUML diagrams.

How to Prepare Moka Coffee:

  1. Fill the base chamber with cold water up to the level of the valve. Insert the filter.
  2. Completely fill the filter with ground coffee, but don’t pack it down.
  3. Make sure the filter and rubber gasket are in place. Screw the two chambers tightly together.
  4. Place the moka pot on the stove. Warning: keep the heat low.
  5. Remove pot from heat just when coffee starts to gurgle, before it starts to rise and bubble. You’ll be sure to extract only the best parts of the coffee.
  6. Mix the coffee with a spoon before pouring into cups.
  7. Rinse the coffee maker with hot water and let dry thoroughly before screwing chambers back together.

From Text to PlantUML Diagram: A Step-by-Step Guide

In practice, creating a PlantUML diagram from text involves defining each step of the process as an element in the diagram, connecting these elements to outline the flow, and optionally adding notes or additional details to clarify complex steps. The result is a diagram that not only serves as a visual aid but also as a living document that evolves alongside the project it describes.

Using Visual Studio Code (VS Code) equipped with the PlantUML plugin revolutionises how we create diagrams. This powerful combination turns VS Code into an efficient environment for drafting and visualizing UML diagrams directly from textual descriptions.

Getting Started: To begin, ensure you have the PlantUML plugin installed in VS Code. This plugin enables you to write PlantUML syntax in a .puml file and preview the resulting diagram in real-time within VS Code. It’s an ideal setup for those who prefer to stay within their coding environment while working on project documentation or architecture planning.

The PUML Code:

@startuml
title How to Prepare Moka Coffee

start
:Fill the base chamber with cold water\nup to the level of the valve;
:Insert the filter;
:Completely fill the filter with ground coffee,\nbut don't pack it down;
:Make sure the filter and rubber gasket\nare in place;
:Screw the two chambers tightly together;
:Place the moka pot on the stove.\nWarning: keep the heat low;
:Remove pot from heat just when coffee\nstarts to gurgle, before it starts to\nrise and bubble;
:Mix the coffee with a spoon before\npouring into cups;
:Rinse the coffee maker with hot water\nand let dry thoroughly before\nscrewing chambers back together;
stop

@enduml

Here’s a step-by-step explanation of each part of the code:

  1. @startuml and @enduml are directives that mark the beginning and end of the PlantUML diagram code, respectively.
  2. title How to Prepare Moka Coffee specifies the title of the diagram. This title will be displayed at the top of the generated diagram to describe what the diagram represents.
  3. start marks the beginning of the activity flow in the diagram. It indicates the start of the process being diagrammed.
  4. Each line starting with : describes an action or step in the process. These are the individual activities that make up the whole process of preparing Moka coffee. Each step is written in plain English and describes a specific action, such as “Fill the base chamber with cold water up to the level of the valve.” The \n sequence is used to insert line breaks, making the text easier to read within the diagram.
  5. stop marks the end of the activity flow in the diagram. It indicates the completion of the process being diagrammed.

This PlantUML code effectively breaks down the coffee-making process into distinct steps, from filling the Moka pot’s base chamber with water to rinsing the coffee maker after use. Once processed by PlantUML, this script will generate a visual diagram that sequentially outlines these steps, providing a clear visual guide on how to prepare Moka coffee. This type of diagram is particularly useful for visual learners or for including in documentation to illustrate a process.

The Result:

Deeper Dive: Advanced PlantUML Representation of the same process

In this section, we’ll explore a more advanced PlantUML code that illustrates the same process. This enhanced diagram incorporates additional elements such as actors and entities to provide a richer visualisation of the coffee-making process.

@startuml
title Brewing Coffee with a Moka Pot

actor "Coffee Enthusiast" as enthusiast
entity "Moka Pot" as mokapot
entity "Stove" as stove

== Preparation ==
enthusiast -> mokapot: Fill the base chamber with cold water\nup to the level of the valve
enthusiast -> mokapot: Insert the filter
enthusiast -> mokapot: Completely fill the filter with ground coffee,\nbut don't pack it down
enthusiast -> mokapot: Make sure the filter and rubber gasket\nare in place
enthusiast -> mokapot: Screw the two chambers tightly together

== Brewing ==
enthusiast -> stove: Place the moka pot on the stove.\nWarning: keep the heat low
stove -> mokapot: Heat until coffee starts to gurgle,\nbefore it starts to rise and bubble

== Completion ==
mokapot -> enthusiast: Signal with soft bubbling sound
enthusiast -> mokapot: Mix the coffee with a spoon before\npouring into cups
enthusiast -> mokapot: Rinse the coffee maker with hot water\nand let dry thoroughly before\nscrewing chambers back together

@enduml

Explanation:
@startuml and @enduml: These are directives that mark the beginning and end of the PlantUML diagram code, respectively.

title: This sets the title of the diagram to “Brewing Coffee with a Moka Pot.”

actor: Defines an actor named “Coffee Enthusiast” represented by a stick figure. The actor represents the person involved in the coffee-making process.

entity: Defines two entities, “Moka Pot” and “Stove,” represented by rectangles. These entities represent physical objects involved in the process.

== Preparation ==, == Brewing ==, == Completion ==: These sections organize the diagram into three main phases: Preparation, Brewing, and Completion.

Arrow notation (->): Indicates the direction of the action or interaction between actors and entities.

Text within arrows (Fill the base chamber…, Place the moka pot on the stove…, etc.): Describes the specific actions or steps taken by the Coffee Enthusiast during each phase of the process. The \n sequence is used to insert line breaks for readability.

: Signal with soft bubbling sound: This line indicates the completion of the brewing process, where the Moka Pot signals the Coffee Enthusiast with a soft bubbling sound.

This PlantUML code effectively represents the steps involved in brewing coffee with a Moka pot, from preparation to completion, using a combination of actors, entities, and arrows to visually depict the process.

The Result:

Conclusion:

In conclusion, PlantUML offers a powerful and intuitive way to visualise complex processes through simple and readable text-based diagrams.

The examples provided in this article demonstrate how PlantUML can streamline the visualisation process, making it accessible to developers, project managers, and technical writers alike.

It’s important to note that the examples presented here are relatively simple and serve as a starting point for exploring the capabilities of PlantUML. PlantUML offers a wide range of features and functionalities that can be leveraged to create even more sophisticated diagrams:

  • Support for Various Diagram Types: In addition to sequence diagrams, PlantUML supports other diagram types such as class diagrams, activity diagrams, and use case diagrams, allowing for comprehensive documentation of software systems.
  • Customization Options: PlantUML provides extensive customization options, allowing users to adjust the appearance of diagrams, including colors, fonts, and styles, to suit their preferences or corporate branding.
  • Integration with IDEs and Documentation Systems: PlantUML seamlessly integrates with popular integrated development environments (IDEs) such as Visual Studio Code, allowing users to write PlantUML code directly within their coding environment and preview the resulting diagrams in real-time. It also integrates well with documentation systems, facilitating the inclusion of diagrams in technical documentation.

By leveraging these features, users can create visually appealing and informative diagrams that enhance communication, collaboration, and understanding within their teams.

Leave a Reply

Your email address will not be published. Required fields are marked *