Scenario:
Create uml diagram declarative using Plant UML in Visual Studio code.
Solution:
You need to install.
- Install:
- Visual studio code -> Extension -> PlantUML
- To create UML's other than sequenc diagram, download Graphviz (https://graphviz.gitlab.io/_pages/Download/Download_windows.html) and install.
- Visual studio code > Preferences > Settings > Plantuml -> Command Args -> Edit [settings.json].
- In settings.json add "plantuml.commandArgs": [
"-DGRAPHVIZ_DOT=..graphviz-2.38\\..\\bin\\dot.exe",
]
Close and reopen
Visual studio code
- File -> New File -> Save as (with .wsd extension)
- Add below to generate Class diagram for User class
@startuml UserRoles
abstract class BaseUser
class Shopper #Yellow
class User #Yellow
{
+ CreateUser (name, hashPassword): id
+ UpdateUser (id, userData) : id
}
class Role
{
+ CreateRole (name) id
}
class UserRole #Yellow
{
- User user
+ AssociateRole (userId, roleId) void
}
UserRole .up.> Role
UserRole .up.> User
BaseUser <|-- User
User <|-- Shopper
@enduml
|
|
- Ctrl + Shift + p -> PlantUML: Preview Current Diagram
- To save to file Ctrl + Shift + p -> Export Current File Diagrams
No comments:
Post a Comment