recursionumlprivatesequence-diagramstaruml

Invoking a private method, within the object on a UML sequence diagram


So I have a class diagram here:

Class diagram

A here's my sequence diagram

Sequence diagram

I'm invoking a method in object of Newton class and in this method I have to invoke a private method fact() which returns me a factorial of a given number. This is the body of that newton() method

float Newton::newton(int n, int k) {
    return fact(n)/(fact(k) * fact(n-k));
}

As you can see fact() is invoked three times. So my question is: do I have to acknowledge (in my sequence diagram) that, fact() is used three times here, and if so - how? Or my sequence diagram is correct?


Solution

  • It depends on the purpose of the diagram:

    In case you're in the first case, note that fact() can be implemented recursively or iteratively. Again an implementation detail. In both case, I'd not show what's behind (is it what you tried to do with message 6?): in the case of a recursive implementation, it would make the diagram terribly complex for something easily understood in the code, whereas it would bring no additional information for the interaction scenario.