7

As far I as I could tell, the proper way to show an object creation in a sequence diagram is with an asynchronous arrow, e.g.,

enter image description here

However, in Java (and other OO languages I have used), as far as I know, a new() operation is blocking.

I noticed that some references (Craig Larman) use a hybrid message (dotted line with filled arrow), e.g.,

enter image description here

Especially when a constructor is involved, it's important that a create be a synchronous call. That is, it will return when the constructor is finished. According to my understanding of asynchronous messages in UML, the :A object would not wait for the constructor of :B to finish.

My students often ask this question, and I suspect there is some history behind this. I'm curious why there is this seeming inconsistency.

2
  • 1
    Do they also ask about UML inheritance letting an object change type including having base classes added with state changes? Personally I have never found UML useful other than giving me a set of shapes I can draw with……. And most programmer has no concept of the meaning of most UML symbols, so UML is little more than a set of class diagrams on most projects.
    – Ian
    Commented Dec 3, 2019 at 17:59
  • UML predates Java/C# being in common use.
    – Ian
    Commented Dec 3, 2019 at 18:00

1 Answer 1

8

Each UML message in an interaction diagram has a unique MessageSort, which are mutually exclusive (section 17.4.2):

synchCall
asynchCall
asynchSignal
createMessage
deleteMessage
reply

The graphical notation of the message is defined depending on MessageSort (section 17.4.4.1):

  • An asynchronous Message (messageSort equals asynchCall or asynchSignal) has an open arrow head.
  • A synchronous Message (messageSort equals synchCall) has a filled arrow head.
  • A reply Message (messageSort equals reply) has a dashed line with either an open or filled arrow head.
  • An object creation Message (messageSort equals createMessage) has a dashed line with an open arrow head.
  • An object deletion Message (messageSort equals deleteMessage) must end in a
  • ...

So, this graphical representation is a convention and you shall not be mislead to derive a semantic from it ! If you see a « create » message with an open arrow head, it's not because it would be asynchronous, but simply because that's the way UML decided to represent the creation.

I agree that it's ambiguous: it looks like a reply message, and it's not consistent with the meaning given to arrow heads. Maybe some improvement to suggest to the UML standard committee ? The market didn't wait: there are already some tools that use normal synchronous message arrows.

6
  • 1
    UML has so many versions now I just laugh when people call it a standard. Commented Dec 3, 2019 at 21:02
  • This explains why I got an unexplained downvote on my question (i.e., shame on you for deriving a semantic from the symbols). Commented Dec 3, 2019 at 21:16
  • @candied_orange I was talking about this UML 2.5.1 specification approved by OMG who has authority on it. I admit calling it abusively a standard, since the official standard is ISO 19505, which corresponds to UML 2.4.1. The differences are minor: 198 CHF (the cost of the older ISO standard compared to the free up-to-date OMG specification) ;-)
    – Christophe
    Commented Dec 3, 2019 at 23:10
  • 2
    Unfortunately I've been subjected to so many misused undefined indecipherable UML dodads that I don't trust that I know what I'm looking at until I beat it out of some one. I'm with the students. "Huh?" Commented Dec 3, 2019 at 23:24
  • 1
    @candied_orange I'm with the students: "OMG!" :) Commented Dec 4, 2019 at 4:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.