PlantUML — это инструмент с открытым исходным кодом, позволяющий создавать диаграммы на основе простых текстовых описаний.
Базовые блоки диаграмм
@startuml
User -> Service : Authenticate
Service --> User : Token
@enduml
Диаграммы классов (Class Diagrams)
Атрибуты классов и видимость
@startuml
class BankAccount {
+String owner
#Integer accountNumber
-Decimal balance
~String branchCode
+deposit(amount : Decimal) : void
-calculateInterest() : Decimal
{static} String bankName
{abstract} getAccountType() : String
}
@enduml
| Модификатор | Видимость |
|---|---|
+ |
Публичный (Public) |
- |
Приватный (Private) |
# |
Защищенный (Protected) |
~ |
Пакетный (Package Private) |
Отношения между классами (Class Relationships)
@startuml
Animal <|-- Dog : Extension / Inheritance
Car *-- Engine : Composition
College o-- Student : Aggregation
Driver ..> Car : Dependency
Interface <|.. Impl : Implementation (Dotted)
@enduml
| Синтаксис | Отношение | Значение |
|---|---|---|
| `< | --` | Обобщение / Наследование |
*-- |
Композиция | Дочерний объект не существует без родителя |
o-- |
Агрегация | Дочерний объект существует независимо |
| `< | ..` | Реализация |
..> |
Зависимость | Временное использование |
Заметки и аннотации
@startuml
class Customer
note left of Customer : Customer identity record
note "Floating standalone note" as N1
@enduml
Диаграммы деятельности (Activity Diagrams)
@startuml
start
:Receive Payment;
if (Verified?) then (yes)
:Fulfill Order;
:Send Email;
else (no)
:Notify Customer;
endif
stop
@enduml