Question

I was wondering, how can one represent "if" statement on a collaboration diagram?

 if (somethingShouldBeDone) {
    //multiple conditions
   // Do it
  } else {
   // Do something else
  }

Can it be represented at all? The thing is ... in my code, fair amount of conditions are checked to determine a variety of actions. If i am going to show the actions, I'd like to explicitly state that actions are caused by particular events.

If possible create an image representation of a solution.

Was it helpful?

Solution

You may use guards for representing the conditions that must be true for a message to be passed.

The following example is equivalent to

if (x<y) {
   object2.message1();
   object3.message3();
} else {
   object2.message2();
}

Example

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top