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.

Fuhrmanator
  • 1,435
  • 9
  • 19
  • 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 Dec 03 '19 at 17:59
  • UML predates Java/C# being in common use. – Ian Dec 03 '19 at 18:00

1 Answers1

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.

Christophe
  • 74,672
  • 10
  • 115
  • 187
  • 1
    UML has so many versions now I just laugh when people call it a standard. – candied_orange Dec 03 '19 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). – Fuhrmanator Dec 03 '19 at 21:16
  • @candied_orange I was talking about [this UML 2.5.1 specification](https://www.omg.org/spec/UML/About-UML/) approved by OMG who has authority on it. I admit calling it abusively a standard, since the official standard is [ISO 19505](https://www.iso.org/standard/32624.html), 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 Dec 03 '19 at 23:10
  • Also worth to mention that UML is much more unified than OOSE, Booch and OMT were, before their authors decided to join forces. – Christophe Dec 03 '19 at 23:16
  • 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?" – candied_orange Dec 03 '19 at 23:24
  • 1
    @candied_orange I'm with the students: "OMG!" :) – Fuhrmanator Dec 04 '19 at 04:50