Usually I used Astah to draw UML diagram to put into design document in MS Word or PowerPoint format. The separation of the source and generated file making management of the UML model file a problem. And also it’s annoying to adjust a large amount of elements by dragging with mouse whenever you add something in the diagram. For a coder, typing on keyboard is faster than drawing with mouse.
Now I switch to PlantUML. Just write UML in its DSL and PlantUML generates the diagram. It supports most of the frequent used UML diagrams, which I use most are sequence diagram, class diagram and state diagram. Then I paste the generated diagram into slides (design document) and keep the “source” in note. No need to wonder where to find original UML model file when I need to update the diagram.
The core of PlantUML is simply a jar file. It parses the text input and depends on dot tool from Graphviz for graph generation (except sequence diagram).
There are a bunch of ways to run PlantUML. I highlight some of them I prefer:
- Online editor. Best choice if you’re too lazy to install anything on your computer.
- Desktop (Windows): PlantUML File Watcher
- Embedded into Octopress blog platform. The below examples are using it.
- IDE plugin. Easy way to keep UML together with source code.
The syntax of PlantUML’s DSL is quite intuitional, you can start to use it by following example.
1 | package ConsentObject <<Rect>> { |
The generated diagram:
A sequence diagram example:
1 | title OAuth 2.0 Authorization Code Grant |