PlantUML es una herramienta de código abierto que permite crear diagramas a partir de descripciones sencillas en texto plano.
Bloques básicos de diagrama
@startuml
User -> Service : Authenticate
Service --> User : Token
@enduml
Diagramas de clases (Class Diagrams)
Atributos de clase y visibilidad
@startuml
class BankAccount {
+String owner
#Integer accountNumber
-Decimal balance
~String branchCode
+deposit(amount : Decimal) : void
-calculateInterest() : Decimal
{static} String bankName
{abstract} getAccountType() : String
}
@enduml
| Modificador | Visibilidad |
|---|---|
+ |
Público (Public) |
- |
Privado (Private) |
# |
Protegido (Protected) |
~ |
Privado de paquete (Package Private) |
Relaciones entre clases (Class Relationships)
@startuml
Animal <|-- Dog : Extension / Inheritance
Car *-- Engine : Composition
College o-- Student : Aggregation
Driver ..> Car : Dependency
Interface <|.. Impl : Implementation (Dotted)
@enduml
| Sintaxis | Relación | Significado |
|---|---|---|
| `< | --` | Generalización / Herencia |
*-- |
Composición | El hijo no puede existir sin el padre |
o-- |
Agregación | El hijo puede existir independientemente |
| `< | ..` | Realización |
..> |
Dependencia | Uso transitorio |
Notas y anotaciones
@startuml
class Customer
note left of Customer : Customer identity record
note "Floating standalone note" as N1
@enduml
Diagramas de actividad (Activity Diagrams)
@startuml
start
:Receive Payment;
if (Verified?) then (yes)
:Fulfill Order;
:Send Email;
else (no)
:Notify Customer;
endif
stop
@enduml