【发布时间】:2014-12-03 23:11:47
【问题描述】:
我通常从事协议建模的任务,这通常涉及 3 个主要方面:
- 逻辑:(if (cond) action 1;else action 2)
- 模块或设备:模块 1 将此消息发送到模块 2,或客户端请求服务器。
- 数据结构:客户端将此数据(param1、param2..)发送到服务器。
我不确定如何在 UML 中以一种可以理解的关系来表示这 3 个元素。
我的主要问题是“如何在 UML 中以一种使它们之间的关系直观的方式表示这 3 个元素?”
- 使用什么主图类型?活动?
- 如何表示模块/设备?泳道?
- 如何表示消息和消息结构?对象+类图?
- 还有其他建议吗?
示例
为了让问题更准确,下面是一个简单的协议:
This is a protocol of synchronization between an user interface and a
server with the program logic.
=Start-up process=
The user set the communication to synchronous (the
user interface have to pull for changes every few seconds, only
possible for low usage and simple programs) or asynchronous (the server
send changes directly to the user interface)
The user also set a general purpose URL (G), that point to the server.
Async
If the communication is async, the UI request to the server for 2 URL:
* R : reception socket, to get informed about changes and update the UI
* S : sending socket, to request for get/set/change/create data in
the server.
The UI open the R socket with the server.
=Live process=
Sync:
If the communication is sync, the client ask to G any get/set/change/
create operation.
Async:
If the communication is async, the client request through S an operation.
The request contain:
* the R ip+port
* The UI element identifier to be updated (only for get operations)
* Data requiere for the operation: the request and requiered data.
The server save for every request following data:
* The user that make the request (for example the R IP+port)
* Unique reference to the UI element that will contain the data
* Unique references to the data to be returned to the client (for example
database.table.rowId.column) The user+ UI element is unique, so a new
data reference will override the old data reference. That is a way from
the server to save what each client is showing.
After any change is made on a data, the new value is sent to every user
that are showing this value through R.
=Shutdown process=
When the client close R, the server may drop/free every saved references
for this user.
-
接下来是我尝试用活动图对其进行建模:
【问题讨论】:
-
模块或设备也可以表示为对象。我同意将消息/事件作为类的一部分的想法,在 UML 中不是很有表现力
-
在这个例子中,客户端是一个设备,服务器是另一个,所有这些逻辑都应该是它们的一部分。如果我将它们表示为对象,如何做到这一点?
-
您可以从这里获得示例图(我将其放在评论中,因为将来链接可能不可用):escain.org/UI_protocol.vpp
-
“URL”是什么意思?
-
在这种情况下,该协议适用于与服务器通信的 Web 用户界面。 URL是服务器的URL,例如:www.example.com/myapp.php
标签: uml