Search code examples
umlclass-diagramsequence-diagram

UML Class Method From Sequence Diagram


How does the direction of a message could determine the method of a class (of a sequence diagram actor) ? I'd say the actor sending the message is the one having the method. Am I correct ?

enter image description here

And the classes For that are

enter image description here

Am I right or is it the other way around ?


Solution

  • "Sending a message" is in most cases the same as "calling a method", which means that if an actor sends a message to the computer, then the computer needs to understand it / implement a method.

    There is a difference (see here 1) but essentially you "send a message" to an object, and the object decides what to do with it, in most cases it implements an appropriate method.

    So to answer your question, the receiver of the message send should implement a method for it, not the sender.

    Perhaps a pseudocode can also illustrate it:

    class A {
        function hello() {
            b.someMessage();
            c.otherMessage();
        }
    }
    
    class B {
        function someMessage() {
            this.selfMessage();
        }
    }
    

    enter image description here