Search code examples
umldiagramsoftware-designsequence-diagram

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?


The picture is taken from the book "UML @ Classroom". The text says "the registration is via e-mail, that is, asynchronous".

In actuality, I believe, there would be no "Student" and "Professor" objects involved in the process. Rather an interface, a call to a mail server and in general, nothing that would tell the viewer of the diagram what is really going on.

That makes sense to me because it has an illustrative purpose. The methods of the classes in the sequence diagram would only resemble the methods in a class diagram at a low level.

If I am tasked with a high level view of class diagram and high level sequence diagrams of a particular interaction, 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?

enter image description here


Solution

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

    Not necessary, all depends on the goal of the sequence diagram, you can have classes at design level (may be allowing to generate code) but having them in a sequence diagram giving a semantic (high) level. You can also show these classes in class/package/... diagrams without low detail so not at design level.

    The only rule is to have diagram saying something useful, and following UML specification of course. Do not forget UML is not a method but a language, it does not indicate how it must be used.

    Remark you can put note in a diagram to help saying explicitly its level/goal in case you are afraid it is confusing because not 100% limited/dedicated to design even using classes part of the design.

    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?

    yes, because the goal is not necessary to show a sequence of calls but for instance a higher level.

    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?

    Of course you can do too.

    Notice a sequence diagram (so in fact an interaction) has limited features, while for instance an activity allows to model a behavior in detail without the same limitations.