14

Suppose I have code like

user = AuthHandler.getLoggedInUser()
user.setName(name)
UserDAO.update(user)

How will the sequence diagram look like?

I did

Is it correct? the user/userDAO part?

Jiew Meng
  • 84,767
  • 185
  • 495
  • 805

2 Answers2

18

Sequence Diagrams doesn't require much detail about the object that is returned.

When an operation is performed in an object / class (rectangles), then, a returning dotted arrow should go back to the line and object where it came from.

uml sequence diagram returning value

If a value is returned (wheter an object or a simple type variable), its identifier should appear over the returning arrow.

Optional "return" tags can appear over the arrows that doesn't explicit return a value.

There are several tutorials on the web, I recommend:

http://www.agilemodeling.com/essays/umlDiagrams.htm

EDIT:

In Sequence Diagrams, The returned object type is indicated by an identifier in the text in each box, such as "user: User" or ":UserDAO".

Then, a complementary class diagram or object diagram, based on the given objects, can provide additional information to the actual Sequence Diagram, using the same class identifier or object identifier, example: "User" or "UserDAO".

Do not confuse the class identifier, with the instance identifier.

Note that in the given figure, some boxes skip the specific object instance identifier, or replace it with an asterisk character.

umlcat
  • 4,091
  • 3
  • 19
  • 29
  • 1
    I was under the impression the return was optional? esp if I use something like `user :=`? – Jiew Meng Nov 05 '11 at 00:09
  • I think that the text tag "return" is optional, but the arrow not. – umlcat Nov 05 '11 at 19:54
  • 1
    Ok so I just looked that up. From **[here](http://www.agilemodeling.com/style/sequenceDiagram.htm)** I read: "Do Not Model a Return Value When it is Obvious What is Being Returned" (under "4. Guidelines for Return Values"). I think if I have something like `obj := getSomething()` or `getSomething():obj` I don't need to model a return? As I can see that it returns from the message call? I think it may lessen the clutter in diagrams, else many calls will have a return line? – Jiew Meng Nov 06 '11 at 02:16
  • As I see, you may skip the text for your value or the "return" tag. However, I thinks its important you add the returning line, as a separate part of the diagram, because it indicates where is the process going on. – umlcat Nov 07 '11 at 15:38
0

Diagram is correct as far as I can see. There's no graphical symbol for showing object flow on sequence diagrams - just parameters in the message as you've shown. (c/f activity diagrams which do have notation for object flow).

hth.

sfinnie
  • 9,854
  • 1
  • 38
  • 44