Sequence diagrams: lifeline control
简介 / Introduction
In sequence diagrams, a participant’s lifeline becomes active at different stages and can be destroyed when its role ends. Both PlantUML and Mermaid provide clean syntax to express these semantics — this article demonstrates the same scenario in both engines.
PlantUML 版
1 | @startuml |
PlantUML uses activate to activate a lifeline, deactivate to release activation, and destroy to terminate it with an × marker. Nested activations can be expressed with color blocks or nested activate blocks.
Mermaid 版
1 | sequenceDiagram |
Mermaid uses the + prefix on an arrow to activate a lifeline and - to release it. The destroy keyword also terminates a lifeline with ×. Color-based activation via activate(name) / deactivate(name) requires plugins; the core syntax relies on +/- arrow modifiers.
对比 / Side-by-side
| Feature | PlantUML | Mermaid |
|---|---|---|
| Activate lifeline | activate <name> |
+ prefix or activate(name) |
| Release activation | deactivate <name> |
- prefix or deactivate(name) |
| Destroy lifeline | destroy <name> |
destroy <name> |
| Nested activation | color blocks or nested activate |
+/- nesting levels |
| Syntax style | imperative keywords | arrow modifiers |
小结 / Wrap-up
Both engines share the same conceptual model: activate with +/activate, release with -/deactivate, and destroy with destroy. PlantUML offers richer visuals (color blocks, nested levels) while Mermaid’s +/- prefix notation is more compact. Choose based on your team’s toolchain and diagram complexity.
- Title: Sequence diagrams: lifeline control
- Author: puml.online
- Created at : 2026-08-31 09:00:00
- Updated at : 2026-08-31 01:06:44
- Link: https://puml.online/blog/sequence-diagram-lifeline-control-en/
- License: This work is licensed under CC BY-NC-SA 4.0.