I’m not sure how to model sub-methods in UML sequence diagram. When in the execution of one method another method is called (from the same class). I tried to give an example below:
How would you guys model this in UML (in a sequence diagram)?
..
car1.drive();
..
…
in Car class:
..
drive(){
this.startEngine();
}
startEngine(){
this.getKey();
this.insertKey();
}
..
a small begin:
objx car1
---- ----
| |
| drive() |
|-------->| startEngine()
| |------------.
| | |
| |<-----------.
| |
But where comes the getKey() method?
Must this be communicated via another sequence diagram? Or is there a way to include sub procedures?
You use a self-message, as in the following:
Note the “stacked” lifelines? Those are activation levels. It shows that the drive method calls startEngine, which then calls getKey followed by insertKey. I’ve left the returns implicit.