目录
里面的图,虽然没有通信图(本来其实我看很多的项目文档也都没有通信图),但是在现实开发非常够用了。PowerDesigner我用的感觉,有点点方便吧,比如正逆向工程之类的。但是图片真的很丑,并且PowerDesigner的线总是歪歪扭扭的,丑死了。有的时候,如果有强迫症的话,在画图就很浪费时间。我从今天开始入坑这个PlantUML
(2025年2月4日更新)
用例图
use case.puml
@startuml
'https://plantuml.com/use-case-diagram
'这是官方的文档,非常详细
:Main Admin: as Admin
(Use the application) as (Use)
'
':两个冒号中间可以写小人的名称:
'(括号里面可以写用例的名称)
'as可以用些写别名
'
User -> (Start)
User --> (Use)
Admin ---> (Use)
'
'只要写右箭头就可以指向了,可以指向小人,也可以指向用例
'右箭头的长短就是箭头在图中的长短
'
note right of Admin : This is an example.
note right of (Use)
A note can also
be on several lines
end note
note "This note is connected\nto several objects." as N2
(Start) .. N2
N2 .. (Use)
'
'加注释,of小人或者用例,但是一定要加上方向ltrb(left top right bottom)
'注释要么要用冒号开始:,要么就加上end note.
'\n换行哈,
'note也是可以as的
'..是虚线连接,可以连接注释哈,其实也可以连接任何东西.小人还是用例都可以的.
'
@enduml
类图
class diagram
@startuml
'https://plantuml.com/class-diagram
'官网的这个类图把UML原理讲的很好,很人话,尤其是聚合和组合的区分也说的很好
'这个教程推荐,并且配合ai可以很好上手
abstract class AbstractList
abstract AbstractCollection
interface List
interface Collection
'这个没啥说的
List <|-- AbstractList
Collection <|-- AbstractCollection
Collection <|- List
AbstractCollection <|- AbstractList
AbstractList <|-- ArrayList
'
'箭头中间加上一竖线|,就是三角形箭头,实现..继承..
'去掉竖线就是普通箭头了
'
class ArrayList {
Object[] elementData
size()
}
'
'类图别忘了写类型
'方法一定要写()
'
enum TimeUnit {
DAYS
HOURS
MINUTES
}
'没啥说..
@enduml
'通义灵码去问就好了
'聚合在plantuml怎么画
'plantuml组合怎么画
思维导图
我觉得这个是亮点,我比较不用做很高大上的思维导图,简单用用,这样就不用下载xmind了,之前用了很久的xmind,我觉得这个也挺够的我用了
MindMap.puml
@startmindmap
'https://plantuml.com/mindmap-diagram
caption figure 1
'题注
title My super title
'图像标题,我不会用到
* <&flag>Debian
** <&globe>Ubuntu
*** Linux Mint
*** Kubuntu
*** Lubuntu
*** KDE Neon
** <&graph>LMDE
** <&pulse>SolydXK
** <&people>SteamOS
** <&star>Raspbian with a very long name
*** <s>Raspmbc</s> => OSMC
*** <s>Raspyfi</s> => Volumio
'这个不要太好理解
'就是数星星的个数
'至于中间的<&star>这些小图标,我不会用到....
'常见的<b>粗体</b><s>删除线</s>
header
My super header
endheader
'图片右上角小字,不会用到
center footer My super footer
'不会用到
legend right
Short
legend
' 不知道
endlegend
@endmindmap
时序图
sequence diagram
@startuml
'https://plantuml.com/sequence-diagram
'很详细,其中自动序号autonumber的使用,一定要看,很宝藏
autonumber
'启动自动标数字,可以有多个autonumber
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
'这里的箭头,调用方法,实线箭头->,
'虚线箭头-->,多一个横杠,其实多很多横杆都行,
'我现在画这个图不想画激活期哈...
@enduml
活动图
Activity Diagram.puml
@startuml
'https://plantuml.com/activity-diagram-beta
'官方文档有写软件测试的活动图实例
'还有循环的,可以试试配合ai
'有的时候还真要写循环,不要老用if指来指去表示循环.
start
:ClickServlet.handleRequest();
':冒号分好之间写活动;
:new page;
if (Page.onSecurityCheck) then (true)
'if(决策)then(达到了什么条件)
'别忘了endif
:Page.onInit();
if (isForward?) then (no)
:Process controls;
if (continue processing?) then (no)
stop
endif
if (isPost?) then (yes)
:Page.onPost();
else (no)
:Page.onGet();
endif
'if-else会有集合点的
:Page.onRender();
endif
else (false)
endif
if (do redirect?) then (yes)
:redirect process;
else
if (do forward?) then (yes)
:Forward request;
else (no)
:Render page template;
endif
endif
stop
'总之只要学会写活动
'写if或者if-else
'就好了
@enduml