Fundamentals 13 min read

Software Engineering and PlantUML Practice

The article explains how software‑engineering’s planning‑to‑maintenance lifecycle benefits from UML, then demonstrates using the open‑source textual tool PlantUML to quickly create version‑controlled use‑case, activity (swimlane), state, sequence, and class diagrams, detailing each syntax element and illustrating real‑world examples.

DeWu Technology
DeWu Technology
DeWu Technology
Software Engineering and PlantUML Practice

Software engineering follows a lifecycle: planning, requirement analysis, design, coding, testing, operation and maintenance. UML supports the stages from requirement analysis to design and coding.

Requirement analysis and design are crucial; many developers skip them. This article demonstrates how to use PlantUML, an open‑source textual UML tool, to create diagrams that are easy to version‑control.

Use‑case diagram (basic version)

@startuml

left to right direction

actor 运营人员 as D
actor 客户端用户 as user

rectangle 晒单有礼(精简版) {
D --> (晒单策略):设置
user --> (晒单)
(晒单) --> (晒单策略):匹配
}
@enduml

The diagram answers “who uses which system to do what”. The article explains each element: @startuml / @enduml delimiters, direction, actors, rectangle, and arrows.

Extended use‑case diagram

@startuml
left to right direction
actor 运营人员 as D
actor 客户端用户 as user

rectangle 晒单有礼(扩展版) {
D --> (设置晒单策略)
(设置晒单策略) .> (设置画像):《include》
(设置晒单策略) .> (设置激励类型):《include》
user --> (查看订单列表)
(查看订单列表) --> (晒单)
(晒单) .> (发动态):《include》
(晒单) .> (匹配晒单策略):《include》
}
@enduml

Additional UML constructs such as include and extend are introduced.

Activity (swimlane) diagram

@startuml
|客户端|
|H5前端|
|ServerAPI|
|CRM后台|

|客户端|
start
|ServerAPI|
if (不符合建圈要求) then
:不展示建圈入口;
stop
else
:展示建圈入口;
|H5前端|
:填写建圈表单;
|ServerAPI|
:提交表单等待审核;
|CRM后台|
if (审核不通过) then
:私信通知不通过;
stop
else
:私信通知通过;
|客户端|
:展示建圈任务入口;
:点击任务入口;
|H5前端|
:展示任务列表;
|ServerAPI|
if (未完成任务) then
:私信通知任务失败;
stop
else
:私信通知任务成功;
|客户端|
:保留自建圈子;
stop
@enduml

The swimlane diagram highlights the flow across different participants.

State diagram example

@startuml
[*] --> 其他订单状态变换
state 其他订单状态变换 {
[*] --> 等待付款
等待付款 --> [*] : 取消支付
等待付款 --> 等待发货 : 支付
等待发货 --> [*] : 取消订单
}
其他订单状态变换 --> 无礼确认收货 : 未命中有礼策略
其他订单状态变换 --> 有礼确认收货 : 命中有礼策略

有礼确认收货 --> 晒单 : 14天后点击确认收货
无礼确认收货 --> 晒单 : 点击确认收货
晒单 --> 查看晒单 : 发布动态
有礼确认收货 --> 晒单有礼 : 点击确认收货
晒单有礼 --> 查看晒单 : 发布动态
查看晒单 --> 有礼查看晒单 : 审核通过发送优惠券
有礼查看晒单 --> 查看晒单 : 领完优惠券
查看晒单 --> [*]
@enduml

It shows states and transitions for order processing.

Sequence diagram for brand selection

@startuml
hide footbox
autonumber

actor "用户" as user
participant "APP" as app
participant "服务端" as tag
participant "数仓" as sc
participant "算法" as alg

==点击品牌入口==
user -> app: 点击品牌入口卡片
activate user
activate app
app -> tag: 调用自选品牌数据接口
activate tag
tag --> app: 返回「无自选品牌数据」
deactivate tag
app -> app: 弹出自选品牌窗口
app -> tag: 访问品牌数据接口
activate tag
tag -> sc: 访问数仓排序数据
activate sc #orange
sc --> tag: 返回品牌排序结果
deactivate tag
deactivate sc
tag -> alg: 查询用户社区偏好品牌
activate alg
alg --> tag
deactivate tag
deactivate alg
tag -> app: 品牌数据(包括默认选项2个)
deactivate tag
app --> user
deactivate app
deactivate user
@enduml

The sequence diagram clarifies interactions among user, app, backend, data warehouse and algorithm components.

Class diagram example

@startuml
interface DuDataFlow {
InfoPosts()
InfoAd()
}
class duDataFlow {
grpc.ClientConn
phpservice.Service
context.Context
InfoPosts()
InfoAd()
}
class grpc.ClientConn{}
class phpservice.Service{}
class context.Context{}
DuDataFlow <|-down- duDataFlow
duDataFlow .> grpc.ClientConn
duDataFlow .> phpservice.Service
duDataFlow .> context.Context
@enduml

It illustrates inheritance ( <|- ) and dependency ( .> ) relationships.

Overall, the article maps the software design process to musical metaphors—prelude (requirement analysis), verse (overview design), and chorus (detailed design)—and demonstrates how PlantUML can efficiently produce use‑case, activity, state, sequence, and class diagrams.

PlantUMLrequirement analysissequence diagramsoftware designState DiagramUML
DeWu Technology
Written by

DeWu Technology

A platform for sharing and discussing tech knowledge, guiding you toward the cloud of technology.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.