2

In a UML sequence diagram, how do I draw the process of creating an array of objects? E.g. (simplest case):

object1.function = function() {
    return [new Object2(), new Object2()];
};

I presume that I just add new participants in order (as in the diagram below), is that correct? But is there any way to emphasize that they are elements of an array?

Thanks in advance.

UML diagram

var Object1 = function() {};
var Object2 = function() {};
var object1 = new Object1();
object1.function = function() {
    return [new Object2(), new Object2()];
};
alert( object1.function() );  // [object Object],[object Object]

1 Answer 1

1

Yes, it's simply that you draw two life lines in your example. Each represents one of the returned instances.

However, if you are creating many instances at once it would in most cases be enough to show a single instance as life line and add a note about the remaining ones. I would refrain from artificial presentation of some stack-like instance blocks. It would be possible when you use stereotyped and define the representation in a guideline along with the profile. That depends on your business domain. I usually stick to Occam.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.