在高层次上期望序列图中 classes 的接口看起来像它们在 class 图中的对应接口是不合理的吗?

At a high level is it unreasonable to expect that the interface of classes in a sequence diagram look like their counterparts in the class diagram?

图取自书本"UML @ Classroom"。文字说 "the registration is via e-mail, that is, asynchronous".

实际上,我相信,过程中不会涉及 "Student" 和 "Professor" objects。而是一个接口,一个对邮件服务器的调用,一般来说,没有什么可以告诉图表的查看者真正发生了什么。

这对我来说很有意义,因为它具有说明性目的。序列图中 classes 的方法仅类似于低级别的 class 图中的方法。

如果我的任务是 class 图的高级视图和特定交互的高级序列图,然后我被问到为什么 class 的 classes ] 图没有序列图的任何方法,我说他们根本不需要有是对的吗?

我是否应该与序列图达成妥协,在该序列图中我尝试进行与程序中将要进行的调用类似的调用?

The methods of the classes in the sequence diagram would only resemble the methods in a class diagram at a low level.

没有必要,一切都取决于序列图的目标,您可以在设计级别 类(可能允许生成代码)但将它们放在序列图中以提供语义(高)等级。您还可以在 class/package/... 图表中显示这些 类,没有低细节,因此不在设计级别。

唯一的规则是要有图表说明有用的东西,当然还要遵循 UML 规范。不要忘记 UML 不是一种方法而是一种语言,它并不表示必须如何使用它。

请注意,您可以将 注释 放在图表中,以帮助明确说明它的 level/goal 以防您担心它会造成混淆,因为它不是 100% limited/dedicated甚至使用设计的 类 部分进行设计。

if I am then asked why the classes of the class diagram don't have any of the methods of the sequence diagram, am I right to say that they simply don't have to?

是的,因为目标不是显示调用序列而是显示更高级别的实例。

Should I reach a compromise with the sequence diagram wherein I try to make the calls similar to what will be going on in the program?

当然你也可以。

请注意序列图(因此实际上 交互 )具有有限的功能,而例如 activity 允许在没有相同限制的情况下对行为进行详细建模。