Accepting that (1) I want to use a sequence diagram and not a class, communication or any other diagram and (2) I am not using official UML specification and am prepared to bend the rules, the question is: Is it possible to demonstrate an object being passed as an argument to a function call on another object? For example, in the snippet below, object1's function "add" takes the argument "object2" (adding their respective properties), but the diagram conceals the fact. Would the aforementioned be acceptable? If so, what is the best way to do it?
var object1 = new O("object1");
var object2 = new O("object2");
object1.add(object2);
alert(object1.name); // object1 + object2
function O(param) {
this.name = param;
this.add = function(param) {
this.name = this.name + " + " + param.name;
};
}
In your example, the only communication between object1 and object2 is that object1 gets the name of object2. You could visualize this by drawing an arrow from object1's lifeline to object2's lifeline, labeled 'get name'.
In practice, the getters are usually not visualized, because too much detail may obfuscate the main flow. The fact that you show that object2 is passed as an argument of a message to object1, already implies that object1 will do something with object2.