PlantUML è uno strumento open source che consente di creare diagrammi a partire da semplici descrizioni di testo normale.
Blocchi diagramma di base
@startuml
User -> Service : Authenticate
Service --> User : Token
@enduml
Diagrammi delle classi (Class Diagrams)
Attributi di classe e visibilità
@startuml
class BankAccount {
+String owner
#Integer accountNumber
-Decimal balance
~String branchCode
+deposit(amount : Decimal) : void
-calculateInterest() : Decimal
{static} String bankName
{abstract} getAccountType() : String
}
@enduml
| Modificatore | Visibilità |
|---|---|
+ |
Pubblico (Public) |
- |
Privato (Private) |
# |
Protetto (Protected) |
~ |
Privato del pacchetto (Package Private) |
Relazioni tra classi (Class Relationships)
@startuml
Animal <|-- Dog : Extension / Inheritance
Car *-- Engine : Composition
College o-- Student : Aggregation
Driver ..> Car : Dependency
Interface <|.. Impl : Implementation (Dotted)
@enduml
| Sintassi | Relazione | Significato |
|---|---|---|
| `< | --` | Generalizzazione / Ereditarietà |
*-- |
Composizione | Il figlio non può esistere senza il genitore |
o-- |
Aggregazione | Il figlio può esistere indipendentemente |
| `< | ..` | Realizzazione |
..> |
Dipendenza | Uso transitorio |
Note e annotazioni
@startuml
class Customer
note left of Customer : Customer identity record
note "Floating standalone note" as N1
@enduml
Diagrammi di attività (Activity Diagrams)
@startuml
start
:Receive Payment;
if (Verified?) then (yes)
:Fulfill Order;
:Send Email;
else (no)
:Notify Customer;
endif
stop
@enduml