Difference between types of messages in sequence d

2019-04-10 02:38发布

问题:

What is the difference between?

Self message Recursive message Re-entrant message

thanks

回答1:

A Self Message is a type of message which represents the execution or operation call in the same object lifeline.

A recursive message is a type of self message that is executed recursively.

A re-entrant message is where you have an object A and and oject B.

  • A makes a call C to B
  • B needs some data from A to complete call C
  • B sends a message to A get the data required to complete call C

The call that B makes to A is called a re-entrant message.

Hope that makes sense!!!



回答2:

The result of a call to E function is used to complete a call to another function in the same lifeline with the E function.

Example: Function Main from lifeline of ControllerC object colect data from EvaluateStudent function (located in StudentC scope) in order to use it as parameter for a call to another function also located in the same scope of StudentC. It is importent that the calls to be performed from outside the scope of StudentC. In our case the calls are performed from ControllerC.

public StudentC
{
    public function int EvaluateStudent(object student) 
    {
       /*... perform complex evaluation here ...*/ 
    }

    public function int IsTopStudents(int score, int acceptanceLevel)
    { 
       return(score > acceptanceLevel); 
    }
}

public ControllerC{     
    Public function Main()
    {
       IsTopStudent(EvaluateStudent(student), 8);
    }
}