UML diagrams with plantUML

This post describes how to use the free plantUML for a set of UML diagrams.

Make use of a text editor, or, as I do, install the extension for LibreOffice. There should also be an add-on for Microsoft Word.

Another option for working with plantUML is an add-on for Atlassian Confluence.

Installation

When using ubuntu as your operation system, the installation is just one command:

sudo apt install plantuml

UML

Unified Modeling Language. The different types of UML.

@startwbs
* UML
** Behavioral
*** Activity Diagrams
*** Interaction Diagrams
**** Sequence Diagrams
**** Communication Diagrams
**** Timing Diagrams
*** State Machine Diagrams
*** Use Case Diagrams
** Structural
*** Class Diagrams
*** Component Diagrams
*** Composite Diagrams
*** Deployment Diagrams
*** Object Diagrams
*** Package Diagrams
@endwbs
Different UML types
Different UML types

Behavioral Diagrams

Activity Diagram

@startuml
(*) --> “Receive Order”
--> === S1 ===
=== S1 === --> “Make Drink”
=== S1 === --> “Make Bakery”
=== S1 === --> “Make Payment”
“Make Drink” --> === S2 ===
“Make Bakery” --> === S2 ===
“Make Payment” --> === S2 ===
--> (*)
@enduml
Activity Diagram
Activity Diagram

Sequence Diagram

@startuml
actor Student as S
participant “Online Bookstore” as OBS
participant “Fulfillment Center” as FC

S -// OBS: Login
S -// OBS: Enter Course Code
OBS -->> S: Provide Total
S -// OBS: Submit Payment
OBS -// FC: Submit Payment
FC -->> OBS: Ship Book(s)
OBS -->> S: Ship Book(s)
@enduml
Sequence Diagram
Sequence Diagram

Communication Diagram

@startuml
rectangle “A Student” as S
rectangle “Online Book Ordering System” as OBOS
rectangle “Fulfillment Center” as FC
rectangle “Books” as B
rectangle “Book Order” as BO

S -right->> OBOS: 1: login
OBOS -down- B
OBOS -down->> FC: 2: submit books\n3: calculate price
FC -- B
FC -down- BO: 4: get quantity
B -right- BO
@enduml
Communication Diagram
Communication Diagram

Timing Diagram

@startuml
robust “Vault” as V
robust “Bio Security Sys” as BIO

@0
V is Off
BIO is Off

@+5
V is On
BIO@5 <-> @20 : {15 ms}

@+15
V is On
BIO is On

@+30
V is Off
BIO is Off
@enduml
Timing Diagram
Timing Diagram

State Machine Diagram

@startuml
hide empty description
[*] -right-> Wait
Wait -right-> Vault
Vault -down-> [*]
Vault -up-> Enable
Enable -left-> Unlock
Unlock -down-> Wait
@enduml
State Machine Diagram
State Machine Diagram

Use Case Diagram

@startuml
left to right direction
skinparam packageStyle rectangle
actor :Student: as S
actor :Instructor: as I

rectangle “Online Grade Book”{
usecase (System Login) as (SL)
usecase (Select Class) as (SC)
usecase (Select Assignment) as (SA)
usecase (Upload Assignment) as (UA)
usecase (Select Student) as (SS)
usecase (Enter Text) as (ET)
usecase (Grade Assignment) as (GA)
S -- (SL)
S -- (SC)
S -- (SA)
S -- (UA)
S -- (ET)
(SL) -- I
(SC) -- I
(SA) -- I
(SS) -- I
(GA) -- I
(UA) -[hidden]> (ET)
(SS) -[hidden]> (GA)
}
@enduml
Use Case Diagram
Use Case Diagram

Structural Diagrams

Class Diagram

@startuml
class Kennel {
animal
breed
name
intake()
discharge()
}
@enduml
Class Diagram
Class Diagram

Component Diagram

@startuml
component [inventory.java] as in
component [customer.java] as cu
component [order.java] as or

in .. or
cu .. or
@enduml
Component Diagram
Component Diagram

Composite Structure Diagram

@startuml
rectangle Microwave as MW
() “Power UI” )-right- MW
() “Time UI” )-down- MW
MW -right- () “Lightning API”
() “Display API” )-up- MW
@enduml
Composite Structure Diagram
Composite Structure Diagram

Deployment Diagram

@startuml
node “Client Terminal” as API{
[Admin Portal Interface]
}

node “Web Server” as WS {
[{web server = apache}]
}

node “Application Server” as AS {
rectangle Database as DB
component [Inventory Application] as IA
IA -down- DB
}

API -- WS : TCP/IP
API -- AS : TCP/IP
@enduml
Deployment Diagram
Deployment Diagram

Object Diagram

@startuml
object “College of Computer Science : OrgUnit” as CCS {
building = “Grace Hopper Hall”
}
object “Computer Science : OrgUni” as CS {
building = “Grace Hopper Hall”
}
object “CS Research Unit : OrgUnit” as CSRU {
building = “Bruce Lee Memorial Center”
}
object “VR Lab : OrgUnit” as VRL {
building = “Innovation Center”
}

CCS -- CS : parent
CCS -- CSRU : parent
CSRU -- VRL : parent
@enduml
Object Diagram
Object Diagram

Package Diagram

@startuml
package Java <<Folder>> {
package Object <<Folder>> {
package AbstractCollection <<Folder>> {
package AbstractList <<Folder>> {
class ArrayList
}
}
}
}
@enduml
Package Diagram
Package Diagram