DEV Community

Sakthivel Balasubramaniam
Sakthivel Balasubramaniam

Posted on

PlantUML is awesome

This post is all about why I felt PlantUML is awesome.

PlantUML is an open-source tool allowing users to create UML diagrams from a plain text language.

You can just write few lines of code to draw your UML diagram. UML diagrams are very important in communicating design implementation, doing these digrams in draw.io or something drawing tool is a time taking task. Playing with touchpad/mouse for long time is less effective.

I have used similar tools in past, like mermaid and graphviz.

Following are the things that made PlantUML different

  • Readability
  • Maintainable
  • Flexible
  • Powerful
  • Customable

Once the UML is designed with plantUML the end result can be extracted out into PNG or SVG. There are plugins that can be easily intergated into IDE's, such as PlantUML for VS Code and PlantUML for IntelliJ.

Also available for Confluence(document manager of Atlassian suite) where the history of the change in design implementation can be tracked easily PlantUML for Confluence

PS: PlantUML is written is java with graphviz underhood :)

PlantUML is a component that allows to quickly write :

  1. Sequence diagram
  2. Usecase diagram
  3. Class diagram
  4. Activity diagram (here is the legacy syntax)
  5. Component diagram
  6. State diagram
  7. Object diagram
  8. Deployment diagram beta
  9. Timing diagram beta

You can find the details documentation of how and what is plantUML.

Here I took a random sequence diagram from internet and tried to replicate the same in PlantUML with few tweeks, the end result was wow!

Sample Sequence diagram

sample sequnce

Sequence diagram with PlantUML

PlantUML sequnce

It's not just a replica, but a much better one.

Here the code that did the magic for us.

@startuml
header Facebook Authentication System
title Facebook Authentication System
footer Page no %page% of %lastpage%

actor user #3c5a99
participant WebBrowser as "Web Browser"
box "Facebook server"
    participant App as "Application"
    participant AuthZ as "Authorization System"
    database FCS as "Facebook Content System"
end box

== Basic flow ==

activate user
user -> WebBrowser : get FB resource
    activate WebBrowser
        WebBrowser -> App : request FB access
        WebBrowser <-- App : <<http redirect>>
        WebBrowser -[#red]> AuthZ : authorize
        WebBrowser <-- AuthZ : permission form
        user <-- WebBrowser : permission form
    deactivate WebBrowser

    user -> WebBrowser : user permission
    activate WebBrowser
        WebBrowser -> AuthZ : process permission
        ... 5 minutes alter ...
        WebBrowser <-- AuthZ : <<http redirect>>

        == Authorization ==
        alt permission granted
            activate App
                group
                WebBrowser -> App : FB authorization code
                        activate AuthZ
                            App ->  AuthZ : FB authorization code
                            App <--  AuthZ : FB authorization code
                        deactivate AuthZ

                        activate FCS
                            App -> FCS : access FB user protected resource
                            App <-- FCS : user protected resource
                            note left FCS: Check with content system
                        deactivate FCS
                 end
            deactivate App

            WebBrowser <-- App : user protected resource
            deactivate WebBrowser

            user <-- WebBrowser  : user protected resource
        else permission not granted
            activate WebBrowser
                activate App
                    WebBrowser -> App : no authorization
                    WebBrowser <-- App : FB resource not available
                deactivate App
            deactivate WebBrowser

            user <-- WebBrowser  : FB resource not available
        end
    deactivate WebBrowser

deactivate user
@enduml
Enter fullscreen mode Exit fullscreen mode

Thanks for reading!!!
:)

Top comments (1)

Collapse
 
complexmathguy profile image
Steven Randolph

UML is awesome and PlantUML provides an excellent declarative means of creating diagrams.