Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I model an object thats returned from a function call in a sequence diagram?

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?

like image 345
Jiew Meng Avatar asked Nov 04 '11 10:11

Jiew Meng


1 Answers

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.

like image 122
umlcat Avatar answered Oct 04 '22 03:10

umlcat