PlantUML Study Overview

PlantUML and Me

In these days, I was using atlassian’s products in my work. There are a lot of products, like JIRA, Bamboo, Stash. But I do like its knowledge management tool, aka Confluence. It is very convenient to manage all of your documents output in development. And there are also a lot of plug-ins in Confluence, to support all kinds of content in pages. Since I need to draw some UML diagrams, I met PlantUML, which is represented as a plug-in in Confluence.

At the very beginning, I was not used to use PlantUML. Because I am used to draw UML diagrams in visual mode, in which I can drag and drop simply to create diagrams I need. More exactly, what I used before are modeling tools, in which it is only part of functions to produce UML diagrams. But PlantUML is not a UML modeling tool, even it’s not a visual UML draw tool. You have to write some codes firstly, and then these codes are rendered as UML diagrams.

In this case, I really didn’t like PlantUML. I could not understand why there was such a tool when everyone is trying to make work visualize and convenient.

But I had no better choice at that time if I want to use Confluence. Yes, I can use pictures instead of PlantUML, it’s true. But there is problem, that pictures can not be maintained, aka I can not update content of pictures conveniently.

In this situation, I had to use PlantUML. Fortunately, when I got used to PlantUML, I found it was really a good way to draw and manage UML diagram in documents like Confluence pages. UML diagrams can be easily described with readable code, and can be rendered as pictures in documents by plug-in.

That’s little story about how I met and got like PlantUML.

And now, let’s take a look on PlantUML.

Overview

PlantUML is component that allow you to write most of UML diagrams, like Sequence, Use Case, Class, Activity, etc. You can find more details at PlantUML official web site. It defines a language to describe the diagrams, and render them to pictures. If you are a programmer, you can get familiar with PlantUML grammar quickly, since it is just another computer language to you.

Here are some diagrams that generated by PlantUML:

Use Case Diagram

Activity Diagram

Sequence Diagram

Class Diagram

These are diagrams generated by PlantUML. More diagrams, you can check them out on PlantUML official web site.

Different with visual UML modeling tools, you can not create diagrams with drag & drop. Instead of mouse, keyboard plays an important role in PlantUML, because all you work in PlantUML is done by typing code like this:

@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response

Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml

The code above generates a sequence diagram below:

Basic Sequence Diagram

To convert code to picture, you have to use some tools. PlantUML provides a tool to do this. You can download it here. It use files of code as input, and output pictures of diagrams, like SVG, PNG. And there are also a lot of other tool, you can make your own choice.

Many text editors and IDEs also integrate PlantUML in them. As I know, like:

I am using Atom and JetBrains’ CLion, both of them are good editors for PlantUML. Specially, CLion support live preview.

That’s all for this chapter.