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,475

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
  • 81,699