如何对序列图中函数调用返回的对象进行建模?
假设我有
user = AuthHandler.getLoggedInUser()
user.setName(name)
UserDAO.update(user)
类似序列图的代码如何?
我做了
正确吗? user/userDAO 部分?
Suppose I have code like
user = AuthHandler.getLoggedInUser()
user.setName(name)
UserDAO.update(user)
How will the sequence diagram look like?
I did
Is it correct? the user/userDAO part?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
序列图不需要有关返回对象的太多详细信息。
当在对象/类(矩形)中执行操作时,返回的虚线箭头应该返回到它来自的线和对象。
如果返回一个值(无论是对象还是简单类型变量),其标识符应该出现在返回的箭头。
可选的“返回”标签可以出现在不显式返回值的箭头上。
网上有几个教程,我推荐:
http://www.agilemodeling.com/essays/ umlDiagrams.htm
编辑:
在序列图中,返回的对象类型由每个框中文本中的标识符指示,例如“user:User”或“:用户DAO”。
然后,基于给定对象的补充类图或对象图可以为实际序列图提供附加信息,
使用相同的类标识符或对象标识符,
例如:“用户”或“UserDAO”。
不要将类标识符与实例标识符混淆。
请注意,在给定的图中,某些框会跳过特定的对象实例标识符,或将其替换为星号字符。
Sequence Diagrams doesn't require much detail about the object that is returned.
When an operation is performed in an object / class (rectangles), then, a returning dotted arrow should go back to the line and object where it came from.
If a value is returned (wheter an object or a simple type variable), its identifier should appear over the returning arrow.
Optional "return" tags can appear over the arrows that doesn't explicit return a value.
There are several tutorials on the web, I recommend:
http://www.agilemodeling.com/essays/umlDiagrams.htm
EDIT:
In Sequence Diagrams, The returned object type is indicated by an identifier in the text in each box, such as "user: User" or ":UserDAO".
Then, a complementary class diagram or object diagram, based on the given objects, can provide additional information to the actual Sequence Diagram,
using the same class identifier or object identifier,
example: "User" or "UserDAO".
Do not confuse the class identifier, with the instance identifier.
Note that in the given figure, some boxes skip the specific object instance identifier, or replace it with an asterisk character.
据我所知,图表是正确的。序列图上没有用于显示对象流的图形符号 - 只是消息中的参数,如您所示。 (c/f 活动图确实有对象流的符号)。
嗯。
Diagram is correct as far as I can see. There's no graphical symbol for showing object flow on sequence diagrams - just parameters in the message as you've shown. (c/f activity diagrams which do have notation for object flow).
hth.